How to find out what events are firing?

D

Dorian

I just started getting a 'no current record' error on an ApplyFilter
statement (it worked fine before). However, the actual error is elsewhere -
in some event being fired. I know the Current event is firing but I think the
error is somewhere else. How can I find out where? I tried setting a
breakpoint and stepping through but it always stops on the ApplyFilter
statement and says "you can't use this statement in this window".

Thanks for any assistance. This has had me stuck for quite a while.
 
A

Allen Browne

Access doesn't provide information on what event triggered a message. It may
be the form's Error event.

If it happens only when you use the ApplyFilter action (in a macro) or
method (in VBA code), then you already know what event is firing (e.g. the
click of a command button?) Some things to try:

1. If the form has unsaved edits, Access must commit (or undo) these before
the filter can be applied. Try doing that explicitly before applying the
filter.
If Me.Dirty Then Me.Dirty = False
Note that this will fail if the record cannot be saved (e.g. required field
missing.)

2. Try setting the Filter property of the form instead of ApplyFilter, e.g.:
Me.Filter = "(SomeField = 99)"
Me.FilterOn = True

(There is also a bug in Access 2002 Service Pack 3 that causes this message
to be triggered wrongly after you have deleted a record.)
 
D

Dorian

Thanks for reply.
It turned out that the cause was a corrupted record in the table being
filtered. All columns said #Error. I dont know what caused this corrupted
record but I deleted it and did a compact/repair and now everything works
fine.

-Dorian
 

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