Does some know how to select two more items in one Combo-box, then use some SQL to display one table?

backupgl 2002-08-11 06:15:52
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!
...全文
39 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
zjq5308 2002-08-11
  • 打赏
  • 举报
回复
I english is very bad. so i can't help you ! I'm very sorry!

7,763

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧