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!

Me.requery - how do I stay with the current record? 1

Status
Not open for further replies.

pyroskliq

Technical User
Jan 17, 2001
29
US
I have a form "Updates" with 4 text box controls that are bound to fields in the table "Names" (fields are "FName", "LName", "DOB", and "Gender".)

There are 4 more unbound text boxes where the user can enter a new "FName", "Lname", etc...then click on the button "Update", which will update the data in the table "Names" from the unbound boxes, and then do a me.requery on the form to update the value in the bound "Fname", "LName", etc...

When I me.requery, it always moves back to the first record, so if I'm at record 500 and do the update, it goes back to the first record in the table.

It didn't always do this, but I've made some sort of change and I can't figure out what I've done. I've even created a whole new table/form and I get the same result.

Is there a way to update the record, me.requery, and stay on the same record on the form?

Thanks in advance.

Brian Turner
bturner114@hotmail.com
 
Try this in the Afterupdate Event of the form. Change the
Me("recordID") to your record PK field, whatever you called it.

Dim lngRecordId As Long

lngRecordId = Me("recordid")

Me.Painting = 0
Me.Requery

With Me.RecordsetClone
.FindFirst "recordid= " & lngRecordId
If Not .NoMatch Then
Me.Bookmark = .Bookmark
End If
End With Life's a journey enjoy the ride...
 
Thanks jazzz.

With a little mod I got it to do exactly what I needed.

I'm still kind of baffled with myself, because I did have it working right before this piece of code, but then some change that I made messed it up.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top