J
jmd
this code collects entries from a listbox and sends it to a query. I get a
run-time error 2001 You cancelled the previous operation. Debug references
line
DoCmd.OpenQuery "qryPayroll_MultiSelect"
Here's the entire code below
Private Sub cmdOK_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("qryPayroll_MultiSelect")
For Each varItem In Me!lboxPayPeriod.ItemsSelected
strCriteria = strCriteria & "tblPayPeriod.MPPID = " & Chr(34) _
& Me!lboxPayPeriod.ItemData(varItem) & Chr(34) & "OR "
Next varItem
strCriteria = Left(strCriteria, Len(strCriteria) - 3)
strSQL = "SELECT * from tblPayPeriod " & _
"WHERE " & strCriteria & ";"
qdf.SQL = strSQL
DoCmd.OpenQuery "qryPayroll_MultiSelect"
Set db = Nothing
Set qdf = Nothing
End Sub
Any help would be greatly appreciated.
run-time error 2001 You cancelled the previous operation. Debug references
line
DoCmd.OpenQuery "qryPayroll_MultiSelect"
Here's the entire code below
Private Sub cmdOK_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("qryPayroll_MultiSelect")
For Each varItem In Me!lboxPayPeriod.ItemsSelected
strCriteria = strCriteria & "tblPayPeriod.MPPID = " & Chr(34) _
& Me!lboxPayPeriod.ItemData(varItem) & Chr(34) & "OR "
Next varItem
strCriteria = Left(strCriteria, Len(strCriteria) - 3)
strSQL = "SELECT * from tblPayPeriod " & _
"WHERE " & strCriteria & ";"
qdf.SQL = strSQL
DoCmd.OpenQuery "qryPayroll_MultiSelect"
Set db = Nothing
Set qdf = Nothing
End Sub
Any help would be greatly appreciated.