Access - Difference between Refresh and Requery

Posted on 2007-10-09
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?

Question by:SharonInGeorgia
    LVL 61

    Expert Comment

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

    LVL 77

    Expert Comment

    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 Comment

    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?  
    LVL 77

    Accepted Solution

    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.


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
    A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
    Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
    Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now