Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

show different queries in subform based on selection from combobox

Status
Not open for further replies.

crnstnsnrd

Technical User
Oct 12, 2001
3
US
I have a form with a combo box:

I also have six different queries based on information from the same table as the combo box:

Is it possible to bring up these queries (in a subform or something) based on what is selected in the combo box

example: combo box has three items (table it is based on has the combo box, 4 numerical fields, and 3 text fields)

1. Terms = Terms of sale
(Query would bring up 4 numeric fields from table)
2. PartNumber = Part number
(Query would bring up 3 text fields from table)
3. ARCodes = Accounts Receivable Codes
(Query would bring up 1 numeric field and 1 text field
from table)

I want to show these queries in the form when I choose from the combo box.

 
Is the form that the combo-box is on based on any table or query? If not, you can just base it on that table and filter it based on the combo-box selection. If it is, you can still put a subform on it--it doesn't even need to be linked if the table the form is based on isn't related, then you can just do similar but alter the subforms sql based on the combo box. I'm not sure from your post if this is exactly what you mean...let me know.
--Jim
 
Your question is a little confusing as Jim says. What it sounds like to me is a variable record source (query) for the subform depending on what is selected in the combo box. If that is the case you can do it easily in the after update event of the combo box with a Select Case structure.

Select Case Me!cboPickQuery
Case is = 1
Forms!MainForm!Subform.RecordSource = "Query1"
case is = 2
Forms!MainForm!Subform.RecordSource = "Query2"
and so forth
End Select

This structure implies that the fields in your subform are all the same for each query. If that is not the case then you might try layering different subforms and then making them visible/invisible as the case arises. Sounds like kind of an ugly solution though.

Uncle Jack
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top