I am using the following code to generate a Report based on the multi items selected in a List Box:
Private Sub Command12_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("QryListLots")
For Each varItem In Me!ListLots.ItemsSelected
strCriteria = strCriteria & "," & Me!ListLots.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 [tblLots] " & _
"WHERE [tblLots].[LotID] IN(" & strCriteria & ");"
qdf.SQL = strSQL
DoCmd.OpenReport "PressWt-DeliveryWt", acViewPreview
Set db = Nothing
Set qdf = Nothing
End Sub
In the above code [LotID] is a Long Integer & it works fine.
What I want to know is if [LotID] is a string how the strCriteria quotes should be.
Thanks
Alex