我在导航子表单中有一个子报表,它使用多选列表框来定义要在同一表单上的子报表中查询和显示的条件。我正在使用这个重新查询
Forms![Main]![NavigationSubform].Form![ETIC By Customer Report].Report.Requery
在整个项目中以这种方式更改报告并且它工作得非常好,但是当我在事件代码中使用它时它不会崩溃它根本不会更新报告视图。如果我单独打开报告,一切都很好并且工作正常。
Private Sub Command83_Click()
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim varItem As Variant
Dim strCriteria As String
Dim strSQL As String
Dim unitstr As TempVar
Set db = CurrentDb()
Set qdf = db.QueryDefs("ETIC by Customer")
For Each i In [Forms]![Main]![NavigationSubform].[Form]! [Combo11].ItemsSelected
strCriteria = strCriteria & "," & Chr(34) & [Forms]![Main]![NavigationSubform].[Form]![Combo11].ItemData(i) & Chr(34)
Next i strCriteria = Mid(strCriteria, 2)
If Len(strCriteria) = 0 Then
MsgBox "You did not select anything." _
, vbExclamation, "Nothing to find!"
Exit Sub
End If
TempVars!unitstr = strCriteria
strSQL = "SELECT DISTINCTROW DPASDataWorkTable.[Work Order Id], DPASDataWorkTable.[Asset Id], DPASDataWorkTable.[Approval Dt], DPASDataWorkTable.[Item Desc], DPASDataWorkTable.[Work Order Status Cd], DPASDataWorkTable.[Closed Dt], DPASDataWorkTable.ETIC, DPASDataWorkTable.Remarks, DPASDataWorkTable.[Parts Bin Location], DPASDataWorkTable.[Completed Deferred], DPASDataWorkTable.[Floor Technician], LIMSData.[MGMT CD], DPASDataWorkTable.[Date Opened (By W/O)], DPASDataWorkTable.[Remarks For FMA], DPASDataWorkTable.Priority, LIMSData.[MASTER MGT CODE], LIMSData.User, LIMSData.[PRG CAT], LIMSData.UNIT, LIMSData.[VEH MAKE TYPE], LIMSData.Org, LIMSData.Status, LIMSData.Shop, LIMSData.[Physical Location], LIMSData.Driveable, [Concatinated Tasks].[Line Items]," & _
"[Concatinated Tasks].[Shop Code], DPASDataWorkTable.[Current Shop], LIMSData.[Physical Location], [MEL Table].[MEL Key], DPASDataWorkTable.[Remaining Hours] AS [Total Remaining], DPASDataWorkTable.[Est Hours] AS [Total Estimated],LIMSData.UNIT As [UNIT]" & _
"FROM [MEL Table] INNER JOIN (LIMSData INNER JOIN ((DPASDataWorkTable INNER JOIN [Concatinated Tasks] ON DPASDataWorkTable.[Work Order Id] = [Concatinated Tasks].[Work Order ID]) INNER JOIN DPASDataSubTable ON DPASDataWorkTable.[Work Order Id] = DPASDataSubTable.[Work Order Id]) ON LIMSData.[Local Key] = DPASDataWorkTable.[Local Asset Key]) ON [MEL Table].[MEL Key] = LIMSData.[MEL Key] " & _
"WHERE LIMSData.Unit IN (" & strCriteria & ") and DPASDataWorkTable.[Work Order Status Cd]=""O-Open"";"
Forms![Main]![NavigationSubform].Form![ETIC By Customer Report].Report.Requery
qdf.SQL = strSQL
Set db = Nothing
Set qdf = Nothing
End Sub