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

Requery a form without going to first record

Status
Not open for further replies.

oxicottin

Programmer
Jun 20, 2008
353
0
0
US
Hello, I used to have a bit of code I found on the net someone wounderfull person wrote that allowed you to requery the form and it wouldnt take you to the first record it would stay on the current record and I cant find it anywhere.... Please help!

Thanks,
SoggyCashew.....
 
You do not stay on the record, but return to it. Something like

Code:
dim PK as long
PK = me.EmployeeID
'requery form
me.requery
'Move back
me.recordset.findfirst "EmployeeID = " & PK

Remmber to use single quotes if your PK is numeric.
 
Thank you MajP! I did some more searching aftermy post and although I couldnt find the exact code I did however find the below code that used Application.Echo which I never herd of? I did a search and it turns on and off screen updating so I noted it in the code below also if anyone finds it usefull. Thanks again!

Code:
Dim varPrimaryKey As Variant
 varPrimaryKey = Me.txtPrimaryKeyField.Value
 Application.Echo False 'Turns off the screen updating so you dont see it go to first record
 Me.Requery
 With Me.RecordsetClone
 .FindFirst "YourPrimaryKeyField=" & varPrimaryKey
 If .NoMatch = False Then Me.Bookmark = .Bookmark
 End With
 Application.Echo True 'Turns back on the screen updating

Thanks,
SoggyCashew.....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top