Requery needed twice

K

Kruppy

I wrote a name seach routine to be sure a new name is not already in the
table. This routine changes a code, if necessary, so that the query in the
main table will include this record. My problem is that when I do a requery
it doesn't find the record unless I do this:

Me.Recordset.Requery
MsgBox ("delay a few seconds")
Me.Recordset.Requery
Me.Recordset.FindFirst "Name_ID = " & IDmode

without the 2 calls to requery (separated with the msgbox delay) the call to
FindFirst is not successful.
 
J

Jack Leach

the DoEvents statement yeilds your code to other pending processes and can be
strategically placed to keep your code from "getting ahead of itself"

Me.Recordset.Requery
DoEvents
Me.Recordset.FindFirst ...


I'm not positive this is looking for, but it may work. I've also seen it
used as so...

DoEvents: DoEvents: DoEvents

.... for a particularly intensive event (it's like any reset button... once
just isn't enough sometimes),

or like so:

While Len(Dir(strFileName)) <> 0
Kill strFileName
DoEvents
Wend

the above makes sure subsequent code does not run until the system finally
fully gets rid of the file...

--
Jack Leach
www.tristatemachine.com

"I haven''t failed, I''ve found ten thousand ways that don''t work."
-Thomas Edison (1847-1931)
 
J

John_G via AccessMonster.com

Hi -

It might be that MS Access has not updated the underlying table/or query when
you issue the Me.Recordset.Requery command. Try using the Refresh method to
force MS Access to apply any pending changes to the tables before requerying:

me.refresh
Me.Recordset.Requery
...

HTH

John
 

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