Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Recordset update problem.. 1

Status
Not open for further replies.

thetambarineman

Technical User
Feb 29, 2000
63
GB
Hello all,

Having a slight problem when saving a record in one of my Access 97 databases. Basically what happens when my record is updated is that the database jumps to the first record in the file. I assume that this is because of the database being re-organised to include the new record. Can anyone suggest a way around this?? I need the record to update- but not fly away off to another record because i need to perform an operation on the data after its been saved..
I've tried moving the recordset forward and then back - but that hasnt worked for some reason..

Thanks in advance and i hope that my explanation isnt confusing...!!

Paul..
 
Are you updating the primary key, or a field that changes the position of this record in the sort order for the form? If so, you might try saving the form's Bookmark property before updating, and restore it afterward.

Dim SavedBookmark As Variant

Private Sub Form_BeforeUpdate
SavedBookmark = Me.Bookmark
End Sub

Private Sub Form_AfterUpdate
Me.Bookmark = SavedBookmark
End Sub

I'm not sure it'll work--Access might be positioning to the new record after the AfterUpdate code runs--but it's worth a try. Rick Sprague
 
I have a prog that saves the exact time the record was saved, then I just do a findlast on the time for the record just saved, thereby keeping it front and center.(so to speak)
 
You can also use the LastModified property of a recordset (DAO) to set the bookmark. i.e. rs.bookmark = rs.lastmodified should work nicely.
 
DSJ1967: I never caught on to the LastModified trick--cool! Rick Sprague
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top