By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,961 Members | 2,492 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,961 IT Pros & Developers. It's quick & easy.

How to clear filter to display all data in ms access 2007?

P: 99
I have a combobox that filters data on the form in the afterupdate event.
Following is the query I have been trying to use to filter data.This code filters data effectively but the problem that I am facing is that when I select "<ALL>" from the combobox no data is displayed.What could be wrong?How can I display all the data of the form on selection of "<ALL>"
Expand|Select|Wrap|Line Numbers
  1. Dim strCriteria As String
  2.    strCriteria = "[Jobno]='" & cboPMNO & "'"
  3.       Set rst = Me.RecordsetClone
  4. If strCriteria = "<ALL>" Then
  5.       Me.FilterOn = False
  6. ElseIf rst.NoMatch Then
  7.       MsgBox "No entry found"
  8. Else
  9.     Me.FilterOn = False
  10.     Me.Filter = strCriteria
  11.     Me.FilterOn = True
  12. End If
Apr 16 '12 #1

✓ answered by MikeTheBike

Hi

Shouldn't this
Expand|Select|Wrap|Line Numbers
  1. If strCriteria = "<ALL>" Then 
be this
Expand|Select|Wrap|Line Numbers
  1. If cboPMNO = "<ALL>" Then 
??

Also you hve not filtered the RecorsetClone before you tested for NoMatch !??


MTB

Share this Question
Share on Google+
2 Replies


Expert 100+
P: 634
Hi

Shouldn't this
Expand|Select|Wrap|Line Numbers
  1. If strCriteria = "<ALL>" Then 
be this
Expand|Select|Wrap|Line Numbers
  1. If cboPMNO = "<ALL>" Then 
??

Also you hve not filtered the RecorsetClone before you tested for NoMatch !??


MTB
Apr 16 '12 #2

P: 99
That's one big point that I was missing.
It shoud be cboPMNO..Thanks a lot.Instead of line#5 I am using this
Expand|Select|Wrap|Line Numbers
  1. Docmd.ShowAllRecords
I am testing for NoMatch and then fiIltering,I think.I thought if I check for NoMatch before this then it's bound to have no match as <ALL> is not in the table.The condition for all records is not filteringI guess.
Apr 16 '12 #3

Post your reply

Sign in to post your reply or Sign up for a free account.