C
Carma via AccessMonster.com
Hi,
I have a report which uses the attached code to filter the report by items
selected in a MultiSelect listbox.
But when i run this code I have the following problems:
When I run this code I get the following error when I select one item from
the
list: Run-time error '3075'. Syntax error in string in query expression '
(PositionExclusion in ('P))'.
If I select two items i get: Run-time error '3075'. Syntax error in string in
query expression '(PositionExclusion in ('P','Y))'.
Could someone please help me with the syntax. Much appreciated!
Private Sub Command103_Click()
Dim strTemp As String
Dim strWhere As String
Dim varSelected As Variant
If Me.chkExcl = True Then
If Me.lstPosExcl.ItemsSelected.Count > 0 Then
strTemp = vbNullString
For Each varSelected In Me.lstPosExcl.ItemsSelected
strTemp = strTemp & "'" & Me.lstPosExcl.ItemData(varSelected) & " ',"
Next varSelected
strWhere = strWhere & _
"PositionExclusion IN (" & Left(strTemp, Len(strTemp) - 2) & ") AND "
End If
End If
If Len(strWhere) > 0 Then
strWhere = Left(strWhere, Len(strWhere) - 5)
End If
DoCmd.OpenReport "RptListUniversaltest", acPreview, , strWhere
Thanks!
I have a report which uses the attached code to filter the report by items
selected in a MultiSelect listbox.
But when i run this code I have the following problems:
When I run this code I get the following error when I select one item from
the
list: Run-time error '3075'. Syntax error in string in query expression '
(PositionExclusion in ('P))'.
If I select two items i get: Run-time error '3075'. Syntax error in string in
query expression '(PositionExclusion in ('P','Y))'.
Could someone please help me with the syntax. Much appreciated!
Private Sub Command103_Click()
Dim strTemp As String
Dim strWhere As String
Dim varSelected As Variant
If Me.chkExcl = True Then
If Me.lstPosExcl.ItemsSelected.Count > 0 Then
strTemp = vbNullString
For Each varSelected In Me.lstPosExcl.ItemsSelected
strTemp = strTemp & "'" & Me.lstPosExcl.ItemData(varSelected) & " ',"
Next varSelected
strWhere = strWhere & _
"PositionExclusion IN (" & Left(strTemp, Len(strTemp) - 2) & ") AND "
End If
End If
If Len(strWhere) > 0 Then
strWhere = Left(strWhere, Len(strWhere) - 5)
End If
DoCmd.OpenReport "RptListUniversaltest", acPreview, , strWhere
Thanks!