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
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)

Signature
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)
> Hello.
>
[quoted text clipped - 25 lines]
> BR
> Claes
Claes D - 14 Nov 2006 19:05 GMT
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:
> That misleading error message ("You canceled the previous operation.")
> usually indicates that you've mistyped the name of a field or table. You
[quoted text clipped - 30 lines]
> > BR
> > Claes
Claes D - 14 Nov 2006 19:32 GMT
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:
> That misleading error message ("You canceled the previous operation.")
> usually indicates that you've mistyped the name of a field or table. You
[quoted text clipped - 30 lines]
> > BR
> > Claes
Van T. Dinh - 15 Nov 2006 02:23 GMT
Try:
Me.Filter = "[Date] Is Null"
I hope you *don't* actually have a Field named "Date"?

Signature
HTH
Van T. Dinh
MVP (Access)
> Hello again.
>
[quoted text clipped - 17 lines]
> BR
> Claes
Claes D - 17 Nov 2006 10:39 GMT
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:
>
[quoted text clipped - 23 lines]
> > BR
> > Claes