I'm trying to change the control source of a subform by the selection of an option in a combobox. Ive created the qrys that i want to be my control source but I have no idea how to write the code for what i want.. Help!
When changing the properties of a subform there are two property boxes. One of them is on the square at the top left of the form. The other is on the outer edge of the form. The source object properties (Outer edge) allows you to select the form for your sub form. The one box at the top left allows you to change your control source... using the drop down box select your query and that should work.
ok maybe i didnt explain it properly.. I have a subform on which there is a combobox. In this combo box there are 12 options, each option has its own query. What i want is for each option to load the query that is related to that option (so there are 12 queries aswell). Im not sure how to do it tho thats the prob.
I may not be interpreting this correctly because the suggestion do no make sense to me. This is what I interpret.
1) You have a subform with a combobox
2) The combo box list Names associated with queries
3) When you select a choice from the combo it should change the recordsource of the subform
4) The mainform recordsource is not an issue
I would have 2 columns in my combobox. The first column is the query name the second is the label. For example.
PriceListAir Air-Edel
The combo properties are something like
bound column: 1
column count: 2
column widths: 0";1"
The value of the combobox is the queryname, however, only the label is shown since the first column is 0 width.
your code becomes in the subform
Code:
Private Sub cmboChoose_AfterUpdate()
Me.RecordSource = Me.cmboChoose.Value
End Sub
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.