0
我在導航子窗體中使用多選列表框來定義條件以查詢並顯示在同一窗體的子報表中的子報表。我正在使用這個詢問導航子窗體中的子報表不會在查詢更改和重新查詢後重新加載
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