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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Docmd.requery 1

Status
Not open for further replies.
Nov 9, 2002
9
US
I have a form that has a subform which a query on it.
On one of the controls on my form i have a field that once info has been entered it will requery the subform and update one of my fields on the form with a new total, this works fine, the only problem is that when it requerys the form, it sends my form back to the first record, i want it to requery and return to the same record i was on.
what is the code to make this happen?
 
You could try Bookmark:

Dim bkm
bkm = Me.RecordsetClone.Bookmark
DoCmd.Requery
Me.Bookmark = bkm


Not tested, but it should work. Error handling is up to you [smile]

Good luck

[pipe]
Daniel Vlas
Systems Consultant
danvlas@yahoo.com
 
Thanks for the help, i am new though
Is that exactly what i typ in my form or do i need to change it?
if thats it as is then that did not work, still goes to the first record
 
How do you requery the form?
Any command button, any event behind a text box, just hitting Shift+F9?
[pipe]
Daniel Vlas
Systems Consultant
danvlas@yahoo.com
 
Not very much info...On Update of a field?
Anyway, I found a mistake in my code...I shouldn't have used the RecordsetClone...


Sub FieldName_AfterUpdate()
Dim bkm
DoCmd.RunCommand acCmdSaveRecord
bkm = Me.Bookmark 'set the bookmark before requery
DoCmd.Requery 'requery
Me.Bookmark = bkm 'go to the bookmark
End Sub

HTH
[pipe]
Daniel Vlas
Systems Consultant
danvlas@yahoo.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top