Requery and return to current record

cmray58

Registered User.
Local time
Today, 08:38
Joined
Mar 24, 2014
Messages
70
I'm having trouble firing the requery command and returning to the current record instead of reverting back to record 1. I picked this up from someone else:

Code:
Dim Curr_Rec
Curr_Rec = Me.CurrentRecord
DoCmd.Echo False
Me.Requery
DoCmd.GoToRecord , , acGoTo, Curr_Rec
DoCmd.Echo True
Me.FirstName.SetFocus

I have this in the after update event of a field. However, it's reverting to the previous record, not the current record. I've attached the DB. Thanks in advance.
 

Attachments

Are you saying the way I'm using fundamentally won't work? Or is there something that needs to be adjusted? I'm trying to avoid redoing the entire thing for a new method.
 
I don't use that method so I'm not sure, but that argument is an offset. I'm not on a computer so can't test.
 
It works for me, in the immediate window.?
However I am not adding a record.

I'd put a breakpoint in the code and walk through it
 
It works for me, in the immediate window.?
However I am not adding a record.

I'd put a breakpoint in the code and walk through it

It's only when you add a new record that I'm seeing the issue. You add the new record, enter the first field (Assessor), go to the last name, enter the last name, hit tab and it changes the record.
 
Try adding
Code:
If Me.dirty then Me.dirty = False
before setting curr_rec

or docmd acsaverecord option
 
Try adding
Code:
If Me.dirty then Me.dirty = False
before setting curr_rec

or docmd acsaverecord option

That didnt work either :(

It's really strange what's happening though. It's not even going to another record number. I.e., it still says record 19 of 19, but the data that displayed is different.
 
Use Paul's method then?
 
Are you saying the way I'm using fundamentally won't work?
Yes, I am saying it is fundamentally wrong. The currentrecord returns the absolute position of a record. So assume you have the records
A
B
D
and you are on D. D is the third record. Now you add C. C Becomes the 3rd record. So your code sends you to C instead of returning to D.
 

Users who are viewing this thread

Back
Top Bottom