How can I determine what part of the code below is causing the error?
Command isn't available in MDE/ADE database
Thanks in advance.
Private Sub cmdOK_Click()
' Declare variables
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()
' Loop through the selected items in the list box and build a text string
If Me!lstCategory.ItemsSelected.Count > 0 Then
For Each varItem In Me!lstCategory.ItemsSelected
strCriteria = strCriteria & "tmp_InvRpts.Category = " & Chr(34) _
& Me!lstCategory.ItemData(varItem) & Chr(34) & "OR "
Next varItem
DoCmd.Close acForm, "frm_WhseCatSelect", acSaveNo
strCriteria = Left(strCriteria, Len(strCriteria) - 3)
Else
strCriteria = "tmp_InvRpts.Category Like '*'"
End If
' Build the new SQL statement incorporating the string
strSQL = "SELECT * FROM tmp_InvRpts " & _
"WHERE " & strCriteria & ";"
DoCmd.OpenReport "rpt_WhseOrderInv1", acViewDesign
Reports![rpt_WhseOrderInv1].RecordSource = strSQL
DoCmd.Close acReport, "rpt_WhseOrderInv1", acSaveYes
DoCmd.OpenReport "rpt_WhseOrderInv1", acViewPreview
' Empty the memory
Set db = Nothing
Set qdf = Nothing
End Sub
Razor1
Command isn't available in MDE/ADE database
Thanks in advance.
Private Sub cmdOK_Click()
' Declare variables
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()
' Loop through the selected items in the list box and build a text string
If Me!lstCategory.ItemsSelected.Count > 0 Then
For Each varItem In Me!lstCategory.ItemsSelected
strCriteria = strCriteria & "tmp_InvRpts.Category = " & Chr(34) _
& Me!lstCategory.ItemData(varItem) & Chr(34) & "OR "
Next varItem
DoCmd.Close acForm, "frm_WhseCatSelect", acSaveNo
strCriteria = Left(strCriteria, Len(strCriteria) - 3)
Else
strCriteria = "tmp_InvRpts.Category Like '*'"
End If
' Build the new SQL statement incorporating the string
strSQL = "SELECT * FROM tmp_InvRpts " & _
"WHERE " & strCriteria & ";"
DoCmd.OpenReport "rpt_WhseOrderInv1", acViewDesign
Reports![rpt_WhseOrderInv1].RecordSource = strSQL
DoCmd.Close acReport, "rpt_WhseOrderInv1", acSaveYes
DoCmd.OpenReport "rpt_WhseOrderInv1", acViewPreview
' Empty the memory
Set db = Nothing
Set qdf = Nothing
End Sub
Razor1