Question : How do I refresh a query on a subform?

I have a two-tabbed form. On tab 1 is a hidden field called ClientID which is a key field that matches the record on display.  On tab 2 is a subform pulling information from another table based on the ClientID.  On this subform is a combo field that uses a query also based on the ClientID.  On tab 1, when I use the record navigation button to advance through the records returned, I see that when I attempt to use the drop down associated with the combo box, it doesn’t keep pace with the current ClientID (which is found on tab1).  It continues to look at data associated with the first record; it’s almost like I need to refresh the query after navigating to a new record.  If that is true, what is the best way of “refreshing” the query?  

I have verified that the query does work and if I execute it alongside the form and refresh the query, it does in fact pull the correct information.

Answer : How do I refresh a query on a subform?

Hi,

you can requery a combobox using the name of the combo box and "Requery", like this:

Me.NameOfCombobox.Requery

If the combobox is inside a subform you need to add the path to it:

Me.NameOfSubformContainer.Form.NameOfCombobox.Requery

If it should be requeried when the record navigation is used you should add this inside the "Form Current" event in the main form which fires on every record change.

Cheers,

Christian
Random Solutions  
 
programming4us programming4us