Manual trigger query/subform

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have one combo box and two unbound subforms that are populated by a query. I want to trigger the two queries each time the value in the combo box is changed. Please verify or advise:
1. I create code in the "On Change" event of the combo box. Do I use an Event Procedure or Macro
2. How to I pass a (one) variable into each query/subform that can be used in the select statement? The value of the variable is determined by the item selected in the combo box.

Thanks
-Warren
 
I would use vba in an Event Procedure for the after update event of the combobox
to execute the queries.

In the queries I would use a reference to the combobox on the form.

Field: SomeFieldToMatch
Criteria: [Forms]![YourFormName]![TheComboboxName]

I would guess that you would need to do something like the following in the
AfterUpdate event code of the combobox

Me.[NameofSubformControl].Form.Requery

Me.[NameofSecondSubformControl].Form.Requery
 
Thank-you. I think I just about have it but I'm still unsure how to pass the parameter (which contains the value gained from the selected row in the combo-box) into the query (which I wrote in SQL). I.e., what does it look like on both the VBA side and the SQL side.
-Warren

John Spencer (MVP) said:
I would use vba in an Event Procedure for the after update event of the combobox
to execute the queries.

In the queries I would use a reference to the combobox on the form.

Field: SomeFieldToMatch
Criteria: [Forms]![YourFormName]![TheComboboxName]

I would guess that you would need to do something like the following in the
AfterUpdate event code of the combobox

Me.[NameofSubformControl].Form.Requery

Me.[NameofSecondSubformControl].Form.Requery

I have one combo box and two unbound subforms that are populated by a query. I want to trigger the two queries each time the value in the combo box is changed. Please verify or advise:
1. I create code in the "On Change" event of the combo box. Do I use an Event Procedure or Macro
2. How to I pass a (one) variable into each query/subform that can be used in the select statement? The value of the variable is determined by the item selected in the combo box.

Thanks
-Warren
 
Back
Top