Problem with filter code

D

Darhl Thomason

In my Access 2003 db, I have a StatusID field that I want to filter on. I
am using check boxes so I can pick multiple filters, but it only works when
one of the check boxes is selected. If I select multiple check boxes, the
filter returns no data. Could someone please look at my filter code and
tell me what I'm missing.

'Select Store Status Filter
If Me.chkCompleted = True Then
If Not IsNull(strFilter) Then strFilter = strFilter & " And "
strFilter = strFilter & "tblStoreData.StatusID = 1"
End If
If Me.chkScheduled = True Then
Me.tglUpcomingStores.Enabled = True
If Not IsNull(strFilter) Then strFilter = strFilter & " And "
strFilter = strFilter & "tblStoreData.StatusID = 2"
End If
If Me.chkPending = True Then
If Not IsNull(strFilter) Then strFilter = strFilter & " And "
strFilter = strFilter & "tblStoreData.StatusID = 3"
End If
'End Select Store Status Filter

If I select the first check box, then the strFilter returns
"tblStoreData.StatusID = 1"
If I select the first and second check box, the strFilter returns
"tblStoreData.StatusID = 1 And tblStoreData.StatusID = 2"
If I select all three check boxes, the strFilter returns
"tblStoreData.StatusID = 1 And tblStoreData.StatusID = 2 And
tblStoreData.StatusID = 3"

As far as I can tell, the filter is correct, but something's not quite
right.

Thanks for any help!

Darhl
 
R

Rob Parker

"... something's not quite right." isn't particularly helpful. What is
wrong?

If you were expecting the filter to return records for which any of the
multiple checkboxes are selected, you need to OR your filter criteria,
rather than AND them. If that's not your problem, please post more details.

HTH,

Rob
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top