Link to home
Start Free TrialLog in
Avatar of ggodwin
ggodwinFlag for United States of America

asked on

Access 2003, Refresh Form Data

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_RefreshDisputesTbl_Click:
    Exit Sub
 
Err_RefreshDisputesTbl_Click:
    MsgBox Err.Description
    Resume Exit_RefreshDisputesTbl_Click
    
End Sub

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of TextReport
TextReport
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
Avatar of Scott McDaniel (EE MVE )
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.
Avatar of ggodwin

ASKER

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?
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
Avatar of ggodwin

ASKER

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

ASKER

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"
Me.Requery
DoCmd.SetWarnings True
End Sub

Open in new window