Printable Version of Topic

Click here to view this topic in its original format

UtterAccess Forums _ Access Forms _ Return To Original Record

Posted by: mike60smart Jan 14 2020, 02:11 AM

Hi Everyone

I have Form where I use a Combobox to select the record to Edit.

After Editing this record I then need to refresh the Form to update some calculations.

I have a Command button to Refresh the Form but it then takes me to the first record in the underlying Table that the Form is based on.

Does anyone know how after I Refresh the Form it stays on the record I am Editing?

Any help appreciated

Posted by: June7 Jan 14 2020, 02:40 AM

Review https://www.devhut.net/2012/10/19/ms-access-vba-requery-a-form-while-remaining-on-the-same-record/

Posted by: Larry Larsen Jan 14 2020, 02:57 AM

Hi Mike

Not sure if this very small routine would help..

CODE
Dim CrId As Integer
CrId = Me.CurrentRecord
Me.Requery
DoCmd.GoToRecord , , acGoTo, CrId

thumbup.gif

Posted by: mike60smart Jan 14 2020, 03:25 AM

Hi Larry

Well that is very very neat.

Works a treat

Many thanks yet again
cheers.gif

Posted by: missinglinq Jan 14 2020, 06:00 AM

Actually, since you say that you "need to refresh the Form to update some calculations" you could probably use Me.Recalc, instead of Me.Requery, which would avoid the problem all together.

Linq ;0)>

Posted by: projecttoday Jan 14 2020, 08:27 AM

I agree with missingling, why move off the record and then back again?

In addition to .Requery and .Recalc, Access offers .Refresh and .Repaint.

Posted by: mike60smart Jan 14 2020, 12:47 PM

Hi missingling

Now that is even better.

I learn something every day

Works a treat

Many thanks
cheers.gif

Posted by: missinglinq Jan 14 2020, 05:41 PM

Glad we could help!

Linq ;0)>