Help with Requery

  • Thread starter mattc66 via AccessMonster.com
  • Start date
M

mattc66 via AccessMonster.com

Hi All,

I am using the Me.Requery command in my code. It works great except when I
have a long list and I am the end of the list. Every time the Me.Requery
executes it takes me back to the first record. Is there a way to refresh my
query data and leave me on the current record?

Thanks
Matt
 
M

Marshall Barton

mattc66 said:
I am using the Me.Requery command in my code. It works great except when I
have a long list and I am the end of the list. Every time the Me.Requery
executes it takes me back to the first record. Is there a way to refresh my
query data and leave me on the current record?


SInce a Requery can reload a different set of records, the
current record always becomes the first record. To
reposition the form's recordset to the record that was the
previous current record, you need to save the old record's
PK field and, after the requery, find that record.

Assuming the PK field is a long integer field:

Dim lngKey As Long
lngKey = Me.PKfield
Me.Requery
Me.Recordset.FindFirst "PKfield=" & lngKey

Normally, you should use the form's RecordsetClone so it
doesn't affect the form if the record is not found (e.g. the
record was deleted), but in your case it won't make any
difference.
 

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