|
syntex error comma
Your Question
syntex error (comma) in query?
I have no idea whay I get this error.
I have warehouse as text, I am using a list box to get my WHs, from the list I get WH In (("381","320)) which makes sence but i get the syntex error (comma) in query expenssion error
Me.Visible = False
Dim i As Integer
Dim str As String
Dim strSQL As String
Dim qdef As DAO.QueryDef
Dim MyDB As DAO.Database
Dim strWhere As String
Dim strIN As String
Dim flgSelectAll As Boolean
Dim varItem As Variant
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "qry_FINALAvailablePhysical-Stock"
'Build the IN string by looping through the listbox
For i = 0 To List7.ListCount - 1
If List7.Selected(i) Then
If List7.Column(0, i) = "All" Then
flgSelectAll = True
End If
strIN = strIN & List7.Column(0, i) & """" & "," & """"
End If
Next i
'Create the WHERE string, and strip off the last comma of the IN string
str = "(""" & Left(strIN, Len(strIN) - 2) & ")"
'If "All" was selected in the listbox, don't add the WHERE condition
If flgSelectAll Then
DoCmd.OpenReport stDocName, acPreview
End If
'Clear listbox selection after running query
For Each varItem In Me.List7.ItemsSelected
Me.List7.Selected(varItem) = False
Next varItem
strSQL = " WH In ( " & str & " )"
DoCmd.OpenReport stDocName, acPreview, , strSQL
|