Return cursor to position before requery on continuous form

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.
 
W

Wayne Morgan

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top