Multiple .Filter Criteria Isn't Working (novice needs help)

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm not well-versed in Access "coding" and really only know what little I've been able to pick up and comprehend from this newsgroup. So the answer to my problem may be simple, but I just can't figure it out. Any help would be greatly appreciated

I have a Main Form (Form1) with a Subform (Subform1). I'm trying to filter the Subform with a Command Button. The purpose of the filter is exclude all records with a "v" in the [N/A] field in SubForm1

The following code does succeed in excluding all the "v" records, but for some reason that I can't figure out, it also excludes records where the [N/A] field is blank

Private Sub Command18_Click(
With Forms!Form1.[Subform1].For
.Filter = "[N/A] <>""v""
.FilterOn = Tru
End Wit
End Su

What I want this Command Button to do is give me all records where the [N/A] field contains any value other than "v" or is blank. I modified the Command code as follows but now I get "Runtime Error '13', Type Mismatch"

Private Sub Command18_Click(
With Forms!Form1.[frm Main].For
.Filter = "[N/A] <>""v""" Or "[N/A] Is Null
.FilterOn = Tru
End Wit
End Su

I've tried every possible syntax alternative I could think of, with and without quotation marks, and nothing works. What's wrong with my code

Many thanks
Pau
 
What I want this Command Button to do is give me all records where the [N/A] field contains any value other than "v" or is blank. I modified the Command code as follows but now I get "Runtime Error '13', Type Mismatch":

NULL is not equal to anything - and it's not UNEQUAL to anything
either! I think all you need to do is move the word OR inside the
quotes:

Private Sub Command18_Click()
With Forms!Form1.[frm Main].Form
.Filter = "[N/A] <>""v"" Or [N/A] Is Null"
.FilterOn = True
End With
End Sub
 
John

PERFECT!! (The one combination of quote marks I didn't think to try.) Now the code is giving me exactly what I'm looking for. Thanks so very much for your help, John - I appreciate it very much

Many thanks
Paul
 
Back
Top