K
kris
Hello,
I have an error when my multiple -select code is executed.The code
looks like
Function s()
Dim frm As Form, ctl As control
Dim varItem As Variant
Dim strSQL As String
Set frm = Forms!first
Set ctl = frm!category
strSQL = "Select * from Table1 where [category]="
For Each varItem In ctl.ItemsSelected
strSQL = strSQL & ctl.ItemData(varItem) & " OR [category]="
Next varItem
'Trim the end of strSQL
strSQL = Left$(strSQL, Len(strSQL) - 2)
CurrentDb.QueryDefs("Query3").SQL = strSQL
End Function
Error-"missing operator in query expression"
I dont know if the above code is right.Please let me know where I went wrong.
I'm new to VB coding and access.
I have an error when my multiple -select code is executed.The code
looks like
Function s()
Dim frm As Form, ctl As control
Dim varItem As Variant
Dim strSQL As String
Set frm = Forms!first
Set ctl = frm!category
strSQL = "Select * from Table1 where [category]="
For Each varItem In ctl.ItemsSelected
strSQL = strSQL & ctl.ItemData(varItem) & " OR [category]="
Next varItem
'Trim the end of strSQL
strSQL = Left$(strSQL, Len(strSQL) - 2)
CurrentDb.QueryDefs("Query3").SQL = strSQL
End Function
Error-"missing operator in query expression"
I dont know if the above code is right.Please let me know where I went wrong.
I'm new to VB coding and access.