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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using first cbo to select query for second cbo 1

Status
Not open for further replies.

StormRyder

Programmer
Sep 7, 2003
11
0
0
US
This would seem to be simple however gray matter is not functioning well yet. Need more grog.

Please provide example and thank you in advance for your help.
 
Row Source of 2nd combo:

"SELECT * FROM tblMyTable WHERE MySearchCriteria = '" & Me!cboMyCombo1 & "'"

HTH...

Ken S.
 
Based on your response I'm not sure I have properly explained my question. So here goes another try.

I have two tables with different fields:
Table1
Table2

I have two queries that selct fields from their associated tables:
Query1
Query2

I have a form with a cbo that selects one of two tasks:
Task1
Task2

The second cbo on the form needs to select an appropriate query based on the previously selected task.

Examples:
If cbo1 selects Task1 then cbo2 uses Query1 that looks at Table1.
cbo1=fruit
cbo2=fields from Query1=criteria for Table1=fruit

If cbo1 selects Task2 then cbo2 uses Query2 that looks at Table2.
cbo1=vegetables
cbo2=fields from Query2=criteria for Table2=vegetables

Does this help? I have seached the web and various sites and have a number of posts relating to field variables but none to table/query variables. Thanks again.
 
Okay...

Create an event procedure on the After Update event of cbo1, like so...

Code:
Private Sub cbo1_AfterUpdate()
Select Case Me!cbo1
     Case "Task1"
          Me!cbo2.RowSource = "Query1"
     Case "Task2"
          Me!cbo2.RowSource = "Query2"
End Select
Me!cbo2.Requery
End Sub

Ken S.
 
Thanks Ken. Worked like a charm. Very good use of the "Case" command.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top