I'm using an Autonumber ID field to identify the records I want from the list.
Can anyone help me with my run-error 3075 on STMT2? Syntax Error(missing operator) in query expression '[qdfMULTI.CustID] in (100',102')'.
Those are the correct items, but when I check my query, it is returning all.
Expand|Select|Wrap|Line Numbers
- Private Sub cmdMULTI_Click()
- Dim ms As DAO.Database
- Dim STMT2 As DAO.QueryDef
- Dim varitem As Variant
- Dim strCriteria As String
- Dim strSQL As String
- Set ms = CurrentDb()
- Set STMT2 = ms.QueryDefs("qrySTMTMM")
- For Each varitem In Me!lstMM.ItemsSelected
- strCriteria = strCriteria & "," & Me!lstMM.ItemData(varitem) & "'"
- Next varitem
- If Len(strCriteria) = 0 Then
- MsgBox "You did not select anything from the list!", vbExclamation, "Nothing to Find!"
- Exit Sub
- End If
- strCriteria = Right(strCriteria, Len(strCriteria) - 1)
- strSQL = "SELECT * FROM qrySTMTMM " & " WHERE [qdfMULTI.CustID] IN (" & strCriteria & ");"
- STMT2.SQL = strSQL
- DoCmd.OpenQuery "MMSGSummaryMULTI"
- Set ms = Nothing
- Set STMT2 = Nothing
- End Sub
STMT2: The correct query and columns show...including CustID
strSQL: strSQL = "SELECT * FROM qrySTMTMM " & " WHERE [qdfMULTI.CustID] IN (100',102');"