Form requery

  • Thread starter Thread starter P
  • Start date Start date
P

P

Hi. I created a save button that runs the following code:

if frmMain.Dirty then frmMain.dirty = false
With frmMain
.AllowEdits = False
End With
....
set rst = frmMain.RecordsetClone
rst.Bookmark = frmMain.Bookmark
frmMain.Requery
frmMain.Bookmark = rst.Bookmark

When I click Save, the form comes up with the previous record showing, one
off the new record. How could I set the form to come up with the newly saved
record? Thank you for your help. P
 
Hi. I created a save button that runs the following code:

if frmMain.Dirty then frmMain.dirty = false
With frmMain
.AllowEdits = False
End With
...
set rst = frmMain.RecordsetClone
rst.Bookmark = frmMain.Bookmark
frmMain.Requery
frmMain.Bookmark = rst.Bookmark

When I click Save, the form comes up with the previous record
showing, one off the new record. How could I set the form to come
up with the newly saved record? Thank you for your help. P
Best way is to grab the primary key from the record and do a .findfirst
instead.

You could try a .movenext if the form's recordset sort order is the
order of date the entry is made, but otherwise you may wind up anywhere.

Bob.
 
You don't really give any reason why you are doing a re-query. However, a
re-query complete re-loads the reocrdset for the form, and thus any bookmark
previous to the query is going to be invalid.

Hence, you have to use the key id IF YOU MUST use a requery.

Anyreason why you don't just force a save with me.refresh? That way, you
only need one line of code:

me.Refresh
 
Back
Top