Im having serious problems getting my head around thisI want to pass a list box (which is called Pract_List) to a paramter query called testquery but for some reason it wont work. The query passes but doesnt produce any results so confused
Private Sub Command_4_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("TESTQUERY")
For Each varItem In Me!Pract_List.ItemsSelected
strCriteria = strCriteria & "," & Me!Pract_List.ItemData(varItem) & ""
Next varItem
If Len(strCriteria) = 0 Then
MsgBox "You did not select anything." _
, vbExclamation, "Nothing to find!"
Exit Sub
End If
strCriteria = Right(strCriteria, Len(strCriteria) - 1)
strSQL = "SELECT [Tbl GMS Assets V2 8th Nov].ID, [Tbl GMS Assets V2 8th Nov].[Asset Id], [Tbl GMS Assets V2 8th Nov].Description, " & _
"[Tbl GMS Assets V2 8th Nov].Manufacturer, [Tbl GMS Assets V2 8th Nov].Model, [Tbl GMS Assets V2 8th Nov].[Serial No], " & _
"[Tbl GMS Assets V2 8th Nov].[Location Details], [Tbl GMS Assets V2 8th Nov].[Asset verified], [Tbl GMS Assets V2 8th Nov].[Old asset Id], " & _
"[Tbl GMS Assets V2 8th Nov].[Additional information], [Tbl GMS Assets V2 8th Nov].[PRACTICE CODE], [Tbl GMS Assets V2 8th Nov].[purchase date], " & _
"[Tbl GMS Assets V2 8th Nov].[Date Asset Checked] FROM [Tbl GMS Assets V2 8th Nov] " & _
"WHERE(([Tbl GMS Assets V2 8th Nov].[PRACTICE CODE]) IN(" & strCriteria & "));"