1,text4前有一个check1 当选中check1时text4中内容将作为查询的条件之一,不选中check1时text4中内容将不作为查询的条件之一     tj3 = jyfind.Text4.Text当 jyfind.Text4.Text="民办"时出 ztj为 单位性质="民办"
同样text5前有一个check2 当选中check2时text5中内容将作为查询的条件之一,不选中check2时text5中内容将不作为查询的条件之一 tj4=jyfind.Text5.Text当 jyfind.Text5.Text="森达集团"时上述两个条件的合成为ztj (单位性质="民办" and  单位="森达集团")
tj5(check3)
tj6(check4)
tj7(check5)
.......
tjn(checkn)
多个
(各位我可能选中某某check  可能不选中某某check ) 
以利于查询 select * from jy where  '"&ztj&"'
2,为什么有时我在数据库中发的提问在页面上见不到呢?

解决方案 »

  1.   

    第一个问是一个任意查询条件组合的问题,我这里有一个实例参考一下:
    Private Sub Command1_Click()
     Dim conn As New ADODB.Connection
     Dim rs As New ADODB.Recordset
     
     Dim strsql As String
     Dim lenstr As Integer
     conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=data.mdb"
     
     strsql = "select * from jbzl where"
     lenstr = Len(strsql)
     If Check1.Value = 1 Then strsql = strsql + " " + "编号='" + Text1.Text + "'"
     If Check2.Value = 1 Then
        If Len(strsql) <> lenstr Then
           strsql = strsql + " " + "and 单位名称='" + Text2.Text + "'"
        Else
           strsql = strsql + " " + "单位名称='" + Text2.Text + "'"
        End If
     End If
     If Check3.Value = 1 Then
        If Len(strsql) <> lenstr Then
           strsql = strsql + " " + "and 企业性质='" + Combo1.Text + "'"
        Else
           strsql = strsql + " " + "企业性质='" + Combo1.Text + "'"
        End If
     End If
     If Check4.Value = 1 Then
        If Len(strsql) <> lenstr Then
           strsql = strsql + " " + "and 软件名称='" + Combo2.Text + "'"
        Else
           strsql = strsql + " " + "软件名称='" + Combo2.Text + "'"
        End If
     End If
      
     rs.Open strsql, conn, adOpenKeyset, adLockPessimistic Set VSFlexGrid1.DataSource = rs
    End Sub
    控件有:check1,text1(编号),check2,text2(单位名称),check3,text3(企业性质),check4,text4(软件名称)