Return cursor to position before requery on continuous form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How do I return the cursor to it where it was prior to a requery issued in an
event (for example "on current") in a continuous form?

Currently it jumps to the first field in the first record after a requery.
 
You need to remember where it was before the requery was issued then move to
that record, if it still exists. To do this you would store the value from a
field that is unique for each record, such as an ID field.

Example:
Dim lngRemember As Long
lngRemember = Me.txtID
Application.Echo False 'optional
Me.Requery
Me.Recordset.FindFirst "[IDField]=" & lngRemember
Application.Echo True 'optional if False not used above

If the record no longer exists, you'll remain at the first record. If it
does exist, you'll move to that record. It may help to turn Echo off while
you do this to reduce screen flicker. Also, if the ID field isn't a long
integer, adjust accordingly.
 
Back
Top