Access 2003, Refresh Form Data

Posted on 2009-02-17
Last Modified: 2013-11-28
I have an append query that inserts data into a table. This table is being viewed through a form. However, I can not see the newly imported data in the form until I close the form and re-open.
I have added a "refresh" button below to refresh the data. However, it is not working?

Table: Dispute
Form: fDispute

Any idea?
Private Sub RefreshDisputesTbl_Click()

On Error GoTo Err_RefreshDisputesTbl_Click

    DoCmd.DoMenuItem acFormBar, acRecordsMenu, 5, , acMenuVer70


    Exit Sub


    MsgBox Err.Description

    Resume Exit_RefreshDisputesTbl_Click


End Sub

Open in new window

Question by:ggodwin
    LVL 28

    Accepted Solution

    You need to do a me.requery after tour DoCmd line. (I don't think a me.refresh will return the new records.)
    Cheers, Andrew
    LVL 84
    To expand on what Andrew said:

    Refresh merely refreshes the current recordset. Therefore, new records would NOT be included in that. If you delete records from that current recordset (or someone else does), those deletes would be included.

    Requery rebuilds the entire recordset, and would include new records by you or other users, as well as deletes and edits.

    You really only need to do a Requery; there's no need to Refresh and Requery.

    Author Comment

    Yes, that worked fine.
    Let me ask an additional question.
    I have the below code to populate the table.

    Is there a way I can add something in here so that it will always "me.requery" before the user every see's that the data is not there?
    LVL 28

    Expert Comment

    You have to trigger it on an event, currently you are using the OnClick event of the button, you could use the OnTimer or the AfterUpdate events but they tend to get messy with your users interaction, often best to keep it simple like you have the command button.
    Cheers, Andrew

    Author Comment

    Can I not use it in the same event that triggers the update to the table? Just after the import if complete?

    Author Comment

    yep it appears to work? I added it and it works fine. Is there anything can go wrong down the line?
    Private Sub ImportDisputes_Click()
    DoCmd.SetWarnings False
    DoCmd.RunSQL "delete * from tempDisputes"
    DoCmd.OpenQuery "qNeedDispute"
    DoCmd.OpenQuery "UpdateDisputetbl"
    DoCmd.SetWarnings True
    End Sub

    Open in new window


    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    In the previous article, Using a Critera Form to Filter Records (, the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
    The first two articles in this short series — Using a Criteria Form to Filter Records ( and Building a Custom Filter ( — discuss in some detail how a form can be…
    With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    730 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

    18 Experts available now in Live!

    Get 1:1 Help Now