Button Click Event of a form with ListBox contains the following code:
Private Sub Command6_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].[Lot#] IN(" & strCriteria & ");"
qdf.SQL = strSQL
DoCmd.OpenReport "PressWt-ShiftingWT", acViewPreview
Set db = Nothing
Set qdf = Nothing
End Sub
The Lot# is a string value. Now I want to replace it with LotID which is Long value. Please help to rewrite the code.
Thanks
Alex