error: 2001 while filtering

S

Slippie

Hi, i've been using vba for quite some time now and i've used filters
lot of times. But now i tried to do the following:

Private Sub grpFilter_AfterUpdate()
If grpFilter = 1 Then
Me.Filter = "Opdracht.OpdrachtAanvaard = 'True'"
Me.FilterOn = True
End If
If grpFilter < 1 Or grpFilter > 1 Then
Me.Filter = ""
Me.FilterOn = False
End If
Exit Sub
End Sub

'Opdracht' is a table which has a field name 'Opdrachtaanvaard', thi
field is true//false. Whenever i click on the radiobuttons in th
grpfilter area i get the following error when i turn on the filter
'error 2001 you canceled last operation'
i really don't see the problem so plz plz help me out if you can

*********************************************************************

Also there's something else, in my forms i sometimes use "UPDATE" o
"INSERT INTO" sql statements and they work fine except for the fac
that when i try to update true//false fields with the value of
variable it never works, it says criteria mismatch etc..
it is possible to use variables (such as strings or integers) in sq
statements? right?
so then that means that maybe it wont work with true//false fields?
i'm so confused right now, plz plz help me =
 
S

Steve Schapel

Slippie,

Try taking the Exit Sub line out of your code... it doesn't achieve
anything except stopping the code before it's finished, after it's
finished, if you see what I mean.

"Opdracht.OpdrachtAanvaard = 'True'" is not correct. The ''s around
the True would imply that it's a text data. Try it like this...
"Opdracht.OpdrachtAanvaard = True"
.... or...
"Opdracht.OpdrachtAanvaard = -1"

This also explains the type mismatch error you are getting with your
Append and Update queries.

- Steve Schapel, Microsoft Access MVP
 

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