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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Refresh or Requery; How and When 1

Status
Not open for further replies.

uncleG

Technical User
Jun 10, 2004
63
US
I have several continuous forms which are directories of records in the system, some are based on Query and some based on Tables. The database is A2K mdb, multi user. To reach a particular record you first open the Directory Form then select the line, then click a button which opens the desired record. When some one changes another record in that list you do not see that change unless you close and open the directory form. I had added a button to refresh via the wizard but it does not seem to work in both Table and Query based forms.
What would be the best way to automatically refresh the directory form when it has the focus to display the most current data, and the correct syntax to make it happen be it Table or Query based?
Thanks, UncleG
 
What you need is:
Me.Requery

But the problem is deciding which event: a button perhaps, or the timer.
 
Hi Remou, always great to see your answers here at Tek-tips, they have helped me on many occasions. I am aware of the Me.Requery command and currently use it via a button on the forms. I was hoping for direction on how to automate this and the best On Event Procedure to attach it to. Currently the directory form stays open behind the single view record form. When the user closes the said record it returns him back to the directory page. At this point I would like it to Requery and show any changes or new records added or changed while he was editing.
Thanks, UncleG
 
How about putting the requery in the close event or button for the opened form:
[tt]Forms!frmDirectory.Requery[/tt]

Or in the Activate event of the directory form:
[tt]Private Sub Form_Activate()
Me.Requery
End Sub[/tt]

And thanks [red]:)[/red]
 
Thank you Remou, This is just what I needed. UncleG
 
Hi Guys
I am just putting together a basic Access course and I have this same problem where I want to reshow the data after a change. I am using a simple continuous form of names and phone numbers. The form has a new record row and I want the list to resequnce after a new record is added. I would normally just do a requery in the after update event but as this is a basic course I don't want to frighten my students with VBA on day one :eek:)

Is there a way of requerying without going to VBA? Maybe through a macro? I had a browse through macro actions but couldn't see how to achieve it. When you're into VBA it's difficult to think outside the box :eek:(

Any help would be most appreciated.
Thanks
Chris

 
To bez999

Create a macro using "Requery" pointing to the control that contains the changed data on the form.
(ex. Me!txtName)
 
Thank you, QuasiHacker, that's just what the doctor ordered :eek:)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top