Access 2007 Apply Filter


J

JDegnan

I have several forms that have command buttons that action apply filter and
propt the user to enter criteria into a dialog box. Prior to access 2007 you
could click and find one after another. In 2007, once you find your criteria,
the button can no longer be actioned. I have added another command button to
show all records thinking that would clear the filter, but when you click the
search button it comes back up with the original filter. Anyone know of a fix?
Here is the code:

DoCmd.ApplyFilter "", "[Search Query]![PART_NO] Between [Type PN] And
[Type PN]"
If (IsNull(Forms!A_PROGRAM.PART_NO)) Then
Beep
MsgBox "No records match thet criteria!", vbOKOnly, "No Records"
DoCmd.Close acForm, "A_PROGRAM"
End If
DoCmd.OpenForm "A_PROGRAM", acNormal, "", "", , acNormal
 
Ad

Advertisements

B

boblarson

Perhaps this:

Me.Filter = "[Search Query]![PART_NO] Between [Type PN] And
[Type PN]"
Me.FilterOn = True
If (IsNull(Forms!A_PROGRAM.PART_NO)) Then
Beep
MsgBox "No records match thet criteria!", vbOKOnly, "No Records"
DoCmd.Close acForm, "A_PROGRAM"
End If
Me.FilterOn = False
Me.Filter = ""

--
Bob Larson
Access World Forums Super Moderator

Tutorials at http://www.btabdevelopment.com

__________________________________
 
J

JDegnan

I tried that and if it finds the search criteria it shows it and then goes
blank. If it doesn't find the criteria it says invalid call or procedure.
When you look at the bottom of the form where the record selecter is there is
also a little box that says unfiltered (when you open the form), Filtered
(when the filter is on) and No Filter (when the filter is off).
Once the filter is on I need a way to make the form say unfiltered. Thats
the only time the dialog box comes up propting the user.
--
Thanks,
JDegnan


boblarson said:
Perhaps this:

Me.Filter = "[Search Query]![PART_NO] Between [Type PN] And
[Type PN]"
Me.FilterOn = True
If (IsNull(Forms!A_PROGRAM.PART_NO)) Then
Beep
MsgBox "No records match thet criteria!", vbOKOnly, "No Records"
DoCmd.Close acForm, "A_PROGRAM"
End If
Me.FilterOn = False
Me.Filter = ""

--
Bob Larson
Access World Forums Super Moderator

Tutorials at http://www.btabdevelopment.com

__________________________________


JDegnan said:
I have several forms that have command buttons that action apply filter and
propt the user to enter criteria into a dialog box. Prior to access 2007 you
could click and find one after another. In 2007, once you find your criteria,
the button can no longer be actioned. I have added another command button to
show all records thinking that would clear the filter, but when you click the
search button it comes back up with the original filter. Anyone know of a fix?
Here is the code:

DoCmd.ApplyFilter "", "[Search Query]![PART_NO] Between [Type PN] And
[Type PN]"
If (IsNull(Forms!A_PROGRAM.PART_NO)) Then
Beep
MsgBox "No records match thet criteria!", vbOKOnly, "No Records"
DoCmd.Close acForm, "A_PROGRAM"
End If
DoCmd.OpenForm "A_PROGRAM", acNormal, "", "", , acNormal
 
Ad

Advertisements


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