我有一个多列表框,然后根据选择过滤查询(下面的代码)。
Private Sub Command39_Click()
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim varItem As Variant
Dim strCriteria As String
Dim strSQL As String
Set db = CurrentDb()
Set qdf = db.QueryDefs("Productivity_WeeklyFinal")
For Each varItem In Me!Combo.ItemsSelected
strCriteria = strCriteria & [Forms]![ProductivityForm]![Combo].ItemData(varItem) & ", "
Next varItem
strSQL = "SELECT Info_ME_Employees.ID, gs_1_week_finalUnion.SampleID,
gs_1_week_finalUnion.Operator, Format$([TestDate],'m/dd/yyyy') AS Test_Date,
gs_1_week_finalUnion.Test FROM Info_ME_Employees INNER JOIN gs_1_week_finalUnion ON
Info_ME_Employees.Full_Name = gs_1_week_finalUnion.Operator" & _
" WHERE Info_ME_Employees.ID IN (" & strCriteria & " )AND gs_1_week_finalUnion.TestDate
Between (Date()-7-Weekday(Date(),2)+1) And (Date()-Weekday(Date(),2)) " & _
" ORDER BY gs_1_week_finalUnion.Operator"
qdf.SQL = strSQL
Set db = Nothing
Set qdf = Nothing
End Sub
然后过滤我的查询。
然后我从这些记录中生成一个报告,然后按操作符对记录进行分组。
我的问题是如何在报表所基于的查询中,在这些记录之间输入填充日期。如果我在查询中使用字段运算符的空字段连接填充日期,它将对空值进行分组。有没有vba方法可以引导我走向正确的方向?谢谢您
1条答案
按热度按时间8aqjt8rx1#
考虑将原始命名查询连接到一个交叉连接查询,该查询包含所有不同的运算符和日期,每个运算符和日期基于您的生产率\u weeklyfinal查询:
交叉连接查询(返回所有可能的匹配对)
最终查询(用于报表)