Hi All,
I have stuck in great trouble.
When I click on command button to view Query which selects StoreNo from List.It works fine if some stores selected.But when I select round about 300 stores from list,it gives runtime error:3360 'query is too complex '.Following is code.
Private Sub Command18_Click()
CurrentDb.QueryDefs("Report").SQL = "SELECT Snumber,System_Type from Store_t where " & GetCriteria()
DoCmd.OpenQuery "Report", acViewPreview
End Sub
<-Function to get Store Nos from List->
Private Function GetCriteria() As String
Dim stDocCriteria As String
Dim varItm As Variant
For Each varItm In Forms![rptStores]!List10.ItemsSelected
stDocCriteria = stDocCriteria & "[Snumber] = " & Forms![rptStores]!List10.Column(0, varItm) & " OR "
Next
If stDocCriteria <> "" Then
stDocCriteria = Left(stDocCriteria, Len(stDocCriteria) - 4)
Else
stDocCriteria = "True"
End If
GetCriteria = stDocCriteria
End Function
Kindly help me.
I have stuck in great trouble.
When I click on command button to view Query which selects StoreNo from List.It works fine if some stores selected.But when I select round about 300 stores from list,it gives runtime error:3360 'query is too complex '.Following is code.
Private Sub Command18_Click()
CurrentDb.QueryDefs("Report").SQL = "SELECT Snumber,System_Type from Store_t where " & GetCriteria()
DoCmd.OpenQuery "Report", acViewPreview
End Sub
<-Function to get Store Nos from List->
Private Function GetCriteria() As String
Dim stDocCriteria As String
Dim varItm As Variant
For Each varItm In Forms![rptStores]!List10.ItemsSelected
stDocCriteria = stDocCriteria & "[Snumber] = " & Forms![rptStores]!List10.Column(0, varItm) & " OR "
Next
If stDocCriteria <> "" Then
stDocCriteria = Left(stDocCriteria, Len(stDocCriteria) - 4)
Else
stDocCriteria = "True"
End If
GetCriteria = stDocCriteria
End Function
Kindly help me.