I have a form with 7 combo boxes to to search various fields in a table in Access 2007. I am trying to construct "dynamic" or conditional SQL for my subroutine, that would only use the values from selected comboboxes for the "where" criteria if a selection has been made, otherwise it will ignore the combo box.
For example if cmb1 is not selected, the where clause should look like:
select * from myTable where myField2= 'value of cmb2' and myField3= 'value of cmb3' and so on
If on the other hand cmb1 is selected, it would be included in the where clause.
How do I create this conditional SQL? or is there a better way to do it?
Thanks.
For example if cmb1 is not selected, the where clause should look like:
select * from myTable where myField2= 'value of cmb2' and myField3= 'value of cmb3' and so on
If on the other hand cmb1 is selected, it would be included in the where clause.
How do I create this conditional SQL? or is there a better way to do it?
Thanks.
Comment