Filter Options

G

Guest

Hello.

I am trying to set a filter to a form.

Heres the code I am trying to use, but I get error 2001 all the time.

If FilterOption = 2 Then
Me.Filter = "Shop = '1'"
Me.FilterOn = True
ElseIf FilterOption = 3 Then
Me.Filter = "Shop = '2'"
Me.FilterOn = True
ElseIf FilterOption = 4 Then
Me.Filter = "Shop = '3'"
Me.FilterOn = True
Else
Me.FilterOn = False
End If

Am I on the wrong track here?

After the error message, I can see that the filter is on, but it hasnt
actually filtered anything.
It still shows all the records even though it says "filtered".

What am I doing wrong?

BR
Claes
 
D

Douglas J. Steele

That misleading error message ("You canceled the previous operation.")
usually indicates that you've mistyped the name of a field or table. You
sure the field in your form is named Shop? You sure it's a text field? (If
it's numeric, remove the single quotes around the numbers in your Filter)
 
G

Guest

Hello.

It was that simple.
It was a numeric field, when it of course should have been a textfield.
When I changed it to text it worked.
Thank you.


"Douglas J. Steele" skrev:
 
G

Guest

Hello again.

With this filter, I got the taste for more, hehe.

I have another field that I realized would be great to filter.
It is a date field, and I would like to filter so that I only see the
records that have a null-value.

Something like

If FilterOption = 2 Then
Me.Filter = "Date = Null"
Me.FilterOn = True
Else
Me.FilterOn = False
End If

I know this is incorrect, but I guess you get the point. :)

BR
Claes


"Douglas J. Steele" skrev:
 
V

Van T. Dinh

Try:

Me.Filter = "[Date] Is Null"

I hope you *don't* actually have a Field named "Date"?
 
G

Guest

Thank you.

No, the filedname is a little more complicated, but I usually "rename" the
fields when asking questions so it is easier for people to understand my
question.

BR
Claes

"Van T. Dinh" skrev:
Try:

Me.Filter = "[Date] Is Null"

I hope you *don't* actually have a Field named "Date"?

--
HTH
Van T. Dinh
MVP (Access)



Claes D said:
Hello again.

With this filter, I got the taste for more, hehe.

I have another field that I realized would be great to filter.
It is a date field, and I would like to filter so that I only see the
records that have a null-value.

Something like

If FilterOption = 2 Then
Me.Filter = "Date = Null"
Me.FilterOn = True
Else
Me.FilterOn = False
End If

I know this is incorrect, but I guess you get the point. :)

BR
Claes
 

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