Me.Requery

Hankwembo Christopher,FCCA,FZICA,CIA,MAAT,B.A.Sc
Hankwembo Christopher,FCCA,FZICA,CIA,MAAT,B.A.Sc used Ask the Experts™
on
I'm now failing to understand this requery property, see the definition below:

Me.Requery forces the entire recordset (underlying data) for the form to reload. This means ALL of the records in your current form will reload. Your current position will be lost, so if you're sitting on record 10 of 100, you'll find yourself back on the first record. Me.Requery is essentially the same as closing and reopening the form. Any new records added by other concurrent users will be available. Likewise any records that have been deleted will disappear. Requery essentially "re-runs the query" that pulled the data into the form in the first place. You can also use requery to update the data in a list box or combo box.

As per above definition is there a difference with the below combination:

Private Sub Refresh_Click()
DoCmd.Save
DoCmd.Close
DoCmd.Opern Form "XXXXXX"
End Sub

Can somebody out clear me on this

Regards

Chris
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
President / Owner
Most Valuable Expert 2017
Most Valuable Expert 2012
Commented:
Well outside of the fact that your going through all the other steps (closing the form, opening, re-creating controls, etc), then no.

 In both cases, you would have a fresh recordset.

 What's your concern/problem?

Jim.
ste5anSenior Developer

Commented:
Sure, there is a difference. Cause one of your assumptions is wrong:

Me.Requery is essentially the same as closing and reopening the form
Closing and reopening can lose more information than a Requery. E.g. form level variables or filters.

And much more: a requery does only raise one event (On Current), whereas closing and reopening would raise a whole bunch of them. Where each event may have effects.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial