The Current event will fire whenever a new record becomes current on the
form. You can't stop it. However, you can have your code choose
whether or not to respond to it. For example, you can set a
module-level variable when you start your search, and clear it when your
search is over. Then the code in the Current event procedure can check
that variable to decide whether or not to to do whatever it is that it
would normally do.
If you don't mind my asking, what kind of search are you doing, that is
going to cause the Current event to fire while it's going on?
If you are "searching" the current forms recordset for some value, you would
be far better off searching a recordsetclone. Then, when you find what you
are looking for, set the forms bookmark property equal to the clones bookmark
property.
As an example, if you have an unbound textbox (txt_FindSSN) in the forms
header, with a command button (cmd_FindSSN), the code behind the button might
look like:
Private Sub cmd_FindSSN
IF len(me.txt_FindSSN & "") <> 9 then Exit sub
Dim rs as dao.recordset
set rs = me.recordsetclone
rs.findFirst "[SSN] = '" & me.txt_FindSSN & "'"
if rs.nomatch then
msgbox "no match for this SSN"
else
me.bookmark = rs.bookmark
endif
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.