Selecting based on ComboBox

G

Guest

I want to show records from different tables on the Main form based on the
selection from a ComboBox. There are at least 2 sub-forms to show different
data from different tables. I want the sub-forms to show only the data based
on the selected value of the combobox. How can I do this?
What I've done so far:
The Main form is bound to Table1.
The Combobox is not bound to the main form.
The sub-forms are bound to the Main form.
There is a bound Textbox. The selected value from the ComboBox is assigned
to the bound Textbox. I then refresh the main form, which in turn refreshes
the sub-forms.
The problem is: The value that is selected in the ComboBox is added back to
Table1, which is not desirable. I've already set the Textbox.locked=Yes.
Any thing I'm doing wrong or not doing?
thanks.
 
G

Graham Mandeno

Hi Samantha

If you alter the value in a bound textbox, it will change the underlying
record, even if the textbox is locked.

The textbox should not be bound. In fact, it is redundant.

Just set the LinkMasterFields properties of the subform controls to the name
of your unbound combo box. Then, changing the selection in the combo box
will automatically requery the subforms to show records with matching
LinkChildFields values. You don't need any code at all - not even a
refresh!
 
G

Guest

Thanks Graham. But it is not giving me an option to choose the ComboBox,
only options are the fields that the Main form is bound to.

Instead I bound the subform's record source to the ComboBox and it seems to
work fine, although it does require a refresh.

thanks

Graham Mandeno said:
Hi Samantha

If you alter the value in a bound textbox, it will change the underlying
record, even if the textbox is locked.

The textbox should not be bound. In fact, it is redundant.

Just set the LinkMasterFields properties of the subform controls to the name
of your unbound combo box. Then, changing the selection in the combo box
will automatically requery the subforms to show records with matching
LinkChildFields values. You don't need any code at all - not even a
refresh!

--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

Samantha said:
I want to show records from different tables on the Main form based on the
selection from a ComboBox. There are at least 2 sub-forms to show
different
data from different tables. I want the sub-forms to show only the data
based
on the selected value of the combobox. How can I do this?
What I've done so far:
The Main form is bound to Table1.
The Combobox is not bound to the main form.
The sub-forms are bound to the Main form.
There is a bound Textbox. The selected value from the ComboBox is
assigned
to the bound Textbox. I then refresh the main form, which in turn
refreshes
the sub-forms.
The problem is: The value that is selected in the ComboBox is added back
to
Table1, which is not desirable. I've already set the Textbox.locked=Yes.
Any thing I'm doing wrong or not doing?
thanks.
 

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