How to use the same query for multiple combo boxes

jlyn123

New Member
Joined
Jan 24, 2018
Messages
48
Office Version
  1. 2016
I have created a form where I have two columns of combo boxes. Once you select a drop down option from your list column you move to the second row and have a selection based on your first column pick. I can get this to work for the first line (row) but need it to work for all rows. Below is my query.

Field: Carrier/Account Number Client/Linecode
Table: tbl_Trion tbl_Trion
Total: Group By Where
Sort: Ascending
Show: check
Criteria: [Forms]![Trion]![txt_client1]

However, I have a list of 20 rows. I don't want to make individual queries for each row [txt_client2]; how can I combine all of these in one so I can use only 1 query?

Thanks
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
cycle thru the controls to build your Where clause...

Code:
'----------------
sub btnOpenQry_click()
'----------------
dim sWhere as string 
dim qdf as querydef


sWhere = " where 1=1"
if not IsNUll(cboST) then sWhere = sWhere & " and [State]='" & cboST & "'"
if not IsNUll(cboCity) then sWhere = sWhere & " and [city]='" & cboCity & "'"
if not IsNUll(cboZip) then sWhere = sWhere & " and [ZipCode]='" & cboZip & "'"


set qdf = currentdb.querydefs("qsMyQry")
qdf.sql = "Select * from table " & swhere
qdf.close
docmd.openquery qdf.name
 
Upvote 0

Forum statistics

Threads
1,224,739
Messages
6,180,674
Members
452,993
Latest member
FDARYABEE

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top