How to force an immediate record-post?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm writing a record to a table. This record has, as its primary key, an
auto-number field. I then immediately re-read the record I just posted, in
order to fetch that number (I need it for a step further down in the code).
However, the RECORDCOUNT of the recordset is 0. When I wait a few moments and
REQUERY, it's 1 (as it should be). It looks like the write is not getting
posted immediately. How can I force it, so my next read gets the newly added
record? I tried a BEGINTRANS and COMMITRANS pair, but that didn't do anything.

Any ideas?

thanks!
 
What are you doing to save the record? Are you using a form to enter the
record? If so, try

If Me.Dirty Then Me.Dirty = False

to save the record.

What is the Record Source and where is it located?
 
The whole project is written in VB. I use RECSET.ADDNEW, load the fields,
then use RECSET.UPDATE.
 
Sorry, since this is an Access forum, I responded with an Access answer. I
suspect that you've hit a timing problem then. Jet hasn't completed the
update before you try using it. There is a command in Access to "flush the
buffer", but I don't know if it will work in VB.

1) There is the dbForceOSFlush switch for the CommitTrans command.
2) Try the DbEngine.Idle command, it also has a switch dbRefreshCache.
 
Back
Top