Manual Trigger a subform query

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
 
M

Marshall Barton

WarrenR said:
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.


Use the combo box's AfterUpdate event (the change event
fires for every keystroke while the combo box has the
focus). The VBA procedure only needs one line:
Me.thesubformcontrol.FORM.Requery

Use a query's parameter with the syntax:
Forms!themainform.thecombobox
 
G

Guest

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 the SQL side?
-Warren
 
M

Marshall Barton

Unless you're doing something more than you've explained so
far, the parameter in the query would look like the example
I posted earlier:

Forms!themainform.thecombobox

If the value from the combo box is not in the bound column,
then use:

Forms!themainform.thecombobox.Column(N)

where N is the zero based number of the column that does
have the value.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top