Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 438
  • Last Modified:

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?

  • 2
1 Solution
- 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.  
SharonInGeorgiaAuthor 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?  
Opening a form is the equivalent of doing a requery. If form1 and form2 are based on the same table, then if you open form2 after you have saved the record in form1,  form2 will be up to date.

If you have both forms open and add a record in form1 (and save it) , form2 will not know about that record unless you requery form (or close and re-open it).

If you have both forms open and change an existing record in form1, form2 will get that change eventually, but will probably get it quicker if you refresh form2.


Featured Post

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now