Requry a Query

Mahoney

Registered User.
Local time
Today, 06:02
Joined
Feb 4, 2009
Messages
28
Hi Everyone,

I have query that runs from an input form, everything is fine, but when ever i got back to the input form and change the value of combobox, where the query has change the records it gives it wont do this automatically i have to hit refresh button on the query to the new result, it there a way it could be done with some sort of code?

many thanks
 
I have a similar situation where I have a list of customers (CustID, Title, Forename, Surname) in a combo box above a number of fields where the customer details can be edited.

I didn't quite understand your exact situation, but to 'refresh' the list whenever you change the value in your combobox you need to add an 'After Update' event.

For example:

Code:
Private Sub COMBOBOXNAME_AfterUpdate()
DoCmd.Requery
End Sub
 
Thanks,

this will refresh the query that will will run after changing the combobox value?
The query will run after choosing a value form the combo box and hit a button
it works fine when i first endter a value from the combobox and hit the button, but if i go back to the input form and change the value and hit the button, it will take me to the query (which the button is linked to) but will keep the reocrds of the previous entry unless i hit refresh at the top of the page,
 
Thanks,

this will refresh the query that will will run after changing the combobox value?
The query will run after choosing a value form the combo box and hit a button
it works fine when i first endter a value from the combobox and hit the button, but if i go back to the input form and change the value and hit the button, it will take me to the query (which the button is linked to) but will keep the reocrds of the previous entry unless i hit refresh at the top of the page,

I apologise because I do not fully understand what you are saying. Yes, the code above will refresh the whole form after changing the value in the combobox. If you want it to 'refresh'/requery the whole form after changing a different area of the form, then you will need to use the same code and set an event on each of those fields also.
 
thanks Kwah,

i have looked around the web, and found out that a report cannot be refreshed, always have to hit the refresh button
thanks again
 
Ah okay.. you never mentioned in your earlier messages that it was a report that you wanted to 'refresh' - I just assumed that since you mentioned forms that you wanted to refresh a form.

Good to see that you managed to help yourself and locate the information.
 
thanks Kwah,

i have looked around the web, and found out that a report cannot be refreshed, always have to hit the refresh button
thanks again
Actually, I do not believe that is true. You could put code in the After Update event of the combo box to "requery" the report.

The simple code to do it is

Reports!YourReportNameHere.Requery

And that would go in the AFTER UPDATE event of the combo box on the form.
 
But, you would also probably want to use the IsLoaded function to find out if the report was loaded before trying to requery it.
 

Users who are viewing this thread

Back
Top Bottom