举例说明,实现如下多条件查询:
Private Sub Command1_Click() Dim jsql jsql = ""
Dim smyregion As String If Check1Value = 1 Then
jsql = "图书名称 like '%" + Text1Text + "%'" End If
If Check2Value = 1 Then If jsql = "" Then
jsql = "作者姓名 like'%" + Text2Text + "%'" Else
jsql = jsql & "and 作者姓名 like'%" + Text2Text + "%'" End If End If
If Check3Value = 1 Then If jsql = "" Then
jsql = "出版社名称 like'%" + Text3Text + "%'" Else
jsql = jsql & "and 出版社名称 like '%" + Text3Text + "%'" End If End If
If Check4Value = 1 Then If jsql = "" Then
jsql = "出版时间 like '%" + Text4Text + "%'" Else
jsql = jsql & "and 出版时间 like '%" + Text3Text + "%'" End If End If
If Check5Value = 1 Then If jsql = "" Then
jsql = "图书类别 like '%" + Text5Text + "%'"
Else
jsql = jsql & "and 图书类别 like '%" + Text5Text + "%'" End If End If
If jsql = "" Then
MsgBox "请选择查询条件!", vbInformation, "图书音像管理系统" Exit Sub Else
Adodc1RecordSource = "select from book where " & jsql Adodc1Refresh End If
If Adodc1RecordsetRecordCount > 0 Then Set DataGrid1DataSource = Adodc1 End If End Sub
Private Sub Command2_Click() Unload Me End Sub
Select Case <变量名>Case<变量值>
……
Case<变量值>
……
End Select
大多与Combo控件使用 类似:
Select Case Combo1List(Combo1ListIndex)
Case <变量值>
……
Case<变量值>
……
End Select
Form_Load()时可以定义初值:
Combo1ListIndex = 0 '---第一个值
Combo1ListIndex = 1 '---第二个值
……依次
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)