Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Requery in Code

Status
Not open for further replies.
Jul 27, 2004
52
0
0
US
I have a control button that will run a query behind the scenes when a user clicks on it. What I would also like to happen is for the main form to refresh this data as well. Any idea what code to use???
 
how do i type that in the code?
it doesn't seem to like me.refresh
or docmd.me.refresh
 
It should be as simple as putting me.refresh under the code for your button.

Taken from the microsoft help file:
Refresh Method
See Also Applies To Example Specifics
The Refresh method immediately updates the records in the underlying record source for a specified form or datasheet to reflect changes made to the data by you and other users in a multiuser environment.

expression.Refresh

expression Required. An expression that returns one of the objects in the Applies To list.

Remarks
Using the Refresh method is equivalent to clicking Refresh on the Records menu.

Microsoft Access refreshes records automatically, based on the Refresh Interval setting on the Advanced tab of the Options dialog box, available by clicking Options on the Tools menu. ODBC data sources are refreshed based on the ODBC Refresh Interval setting on the Advanced tab of the Options dialog box. You can use the Refresh method to view changes that have been made to the current set of records in a form or datasheet since the record source underlying the form or datasheet was last refreshed.

The Refresh method shows only changes made to records in the current set. Since the Refresh method doesn't actually requery the database, the current set won't include records that have been added or exclude records that have been deleted since the database was last requeried. Nor will it exclude records that no longer satisfy the criteria of the query or filter. To requery the database, use the Requery method. When the record source for a form is requeried, the current set of records will accurately reflect all data in the record source.

Notes

It's often faster to refresh a form or datasheet than to requery it. This is especially true if the initial query was slow to run.
Don't confuse the Refresh method with the Repaint method, which repaints the screen with any pending visual changes.
Example
The following example uses the Refresh method to update the records in the underlying record source for the form Customers whenever the form receives the focus:

Private Sub Form_Activate()
Me.Refresh
End Sub

James Goodman MCSE, MCDBA
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top