I am going to set some criteria to display table results. In my database (Microsoft Access) I have a table (tblResults) with the following fields
ID, contents, field1, field2, field3 as shown following
id contents Field1 Field2 Field3
1 C1 A1 B1 D1
2 C2 A2 B2 D2
3 C3 A1 B2 D1
4 C4 A3 B1 D3
5 C5 A2 B3 D2
6 C6 A3 B3 D3
7 C7 A1 B2 D4
8 C8 A4 B3 D3
On the form of Visual Basic I have
1. A DataControl (Data1) with its database property set to my database and its recordsource left blank
2. A Flexgrid (Flex1) with its datasource set to the datacontrol
3. 2 Combo Box (Combo1 and Combo2) to select the criteria
4. A command button (cmdTable) to do the search and display results
I can set two criteria to two different fields, then get the table results by the following codes. For example select A1 in Field1, and selcet B2 in Field2, then press the commond button to get the table results.
-------------------------------------------------
mySQL = "SELECT * FROM tblResults WHERE ((tblResults.field1) like '" & Combo1.Text & "*' And (tblResults .field2) like '" & Combo2.Text & "*')"
---------------------------------------------------
But now I am going to select two more options in one field first, for example, select (A1 and A2), or (A1 and A3) or (A1, A2 and A4) or (A2, A3 and A4) and so on from Field 1, then select only one record(B1, B2 or other) from Field2, then press common button to show the table. How can I select more options in one field then display the table? Dose it mean that I must add more Combo Box, but even for me, I do not know how many I should add because the option number is not fixed.
I hope someone can solve this problem.
Thanks a lot in advance! Chuan Wang
Royal Institute of Technology
Stockholm, Sweden
Homepage:
ID, contents, field1, field2, field3 as shown following
id contents Field1 Field2 Field3
1 C1 A1 B1 D1
2 C2 A2 B2 D2
3 C3 A1 B2 D1
4 C4 A3 B1 D3
5 C5 A2 B3 D2
6 C6 A3 B3 D3
7 C7 A1 B2 D4
8 C8 A4 B3 D3
On the form of Visual Basic I have
1. A DataControl (Data1) with its database property set to my database and its recordsource left blank
2. A Flexgrid (Flex1) with its datasource set to the datacontrol
3. 2 Combo Box (Combo1 and Combo2) to select the criteria
4. A command button (cmdTable) to do the search and display results
I can set two criteria to two different fields, then get the table results by the following codes. For example select A1 in Field1, and selcet B2 in Field2, then press the commond button to get the table results.
-------------------------------------------------
mySQL = "SELECT * FROM tblResults WHERE ((tblResults.field1) like '" & Combo1.Text & "*' And (tblResults .field2) like '" & Combo2.Text & "*')"
---------------------------------------------------
But now I am going to select two more options in one field first, for example, select (A1 and A2), or (A1 and A3) or (A1, A2 and A4) or (A2, A3 and A4) and so on from Field 1, then select only one record(B1, B2 or other) from Field2, then press common button to show the table. How can I select more options in one field then display the table? Dose it mean that I must add more Combo Box, but even for me, I do not know how many I should add because the option number is not fixed.
I hope someone can solve this problem.
Thanks a lot in advance! Chuan Wang
Royal Institute of Technology
Stockholm, Sweden
Homepage: