L
Letica via AccessMonster.com
I've a MultiSelect listbox (named : lbLocation)in my form (named:101 :
Inventories). After selecting the items in this listbox and click the
RunQuery command button, the following code will be executed :
Private Sub RunQuery_Click()
Dim frm As Form, ctl As Control
Dim varLoc As Variant
Dim strSQL As String
Set frm = Forms![101 : Inventories]
Set ctl = frm!lbLocation
strSQL = "Select * from [101 : Inventories] where Location="
For Each varLoc In ctl.ItemsSelected
strSQL = strSQL & "'" & ctl.ItemData(varLoc) & "' OR Location="
Next varLoc
strSQL = Left$(strSQL, Len(strSQL) - 13)
DoCmd.RunSQL strSQL
End Sub
But, it stops at "DoCmd.RunSQL strSQL" and prompts following error message :
Run-time error ‘2342’
A RunSQL action requires an argument consisting of an SQL statement.
Please help..
Inventories). After selecting the items in this listbox and click the
RunQuery command button, the following code will be executed :
Private Sub RunQuery_Click()
Dim frm As Form, ctl As Control
Dim varLoc As Variant
Dim strSQL As String
Set frm = Forms![101 : Inventories]
Set ctl = frm!lbLocation
strSQL = "Select * from [101 : Inventories] where Location="
For Each varLoc In ctl.ItemsSelected
strSQL = strSQL & "'" & ctl.ItemData(varLoc) & "' OR Location="
Next varLoc
strSQL = Left$(strSQL, Len(strSQL) - 13)
DoCmd.RunSQL strSQL
End Sub
But, it stops at "DoCmd.RunSQL strSQL" and prompts following error message :
Run-time error ‘2342’
A RunSQL action requires an argument consisting of an SQL statement.
Please help..