We help IT Professionals succeed at work.

Access - Difference between Refresh and Requery

803 Views
Last Modified: 2012-08-13
Please explain the difference between refresh and requery.  My application is focused on having the user select a value from a combo box.  That value is transfered between several forms using OpenArgs.  Which one, refresh or requery,  should I use for the following and where should it be placed?

-The combo box OpenArg opens up a form that allows the user to add a new record directly from a form.  Do I need to refresh or requery the table and the combo box?   Where should my refresh/requery be placed in the code?  
- The combo box OpenArg opens up a form and a subform  that allows the user to add a new record.  Do I need to refresh the Main and subform?   Where should the refresh/requery be placed in the code?
- What other suggestions do you have as far as placing a refresh or requery throughout the application?

Comment
Watch Question

CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2013

Commented:
- Refresh will commit a record (for example one that you have been editing in a form) to the underlying recordsource.  As an example, this can be used to make sure that a table is updated before opening  a report from a form.

- Requery will update data shown in a form, combo rowsource, etc with updated values from the underlying table.  You would use this to display current data reflecting any changes that have been made behind the scenes.


CERTIFIED EXPERT

Commented:
Refresh will update all existing records in the relevant recordset with changes made elsewhere.
It does not deal with new records or deletions.
Requery will do all changes plus new records and deletions.  

Author

Commented:
Some of my forms allows the user to add a record.  Other forms are used just for updating a record.  The challenge here is that one form is dependent on the values added or changed of a previous form.   It is a good practice to add refresh and requery to the code in after update?  
CERTIFIED EXPERT
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.