Link to home
Start Free TrialLog in
Avatar of SharonInGeorgia
SharonInGeorgia

asked on

Access - Difference between Refresh and Requery

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?

Avatar of mbizup
mbizup
Flag of Kazakhstan image

- 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.


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.  
Avatar of SharonInGeorgia
SharonInGeorgia

ASKER

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?  
ASKER CERTIFIED SOLUTION
Avatar of peter57r
peter57r
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial