Function myQuery()
Dim strSQL As String
Dim strXB As String
Dim strHY As String
strSQL = "SELECT * from 患者资料"
strSQL = strSQL & " WHERE 1=1" '设一个永远存在的条件,目的是让WHERE先存在,下面的条件直接就可以使用AND联了
If Me.Check0 Then strXB = strXB & "'男'" & ","
If Me.Check1 Then strXB = strXB & "'女'" & ","
If Me.Check2 Then strHY = strHY & "'未婚'" & ","
If Me.Check3 Then strHY = strHY & "'已婚'" & ","
If Me.Check4 Then strHY = strHY & "'离异'" & ","
If Me.Check5 Then strHY = strHY & "'丧偶'" & ","
If Len(strXB) Then strXB = Left(strXB, Len(strXB) - 1)
If Len(strHY) Then strHY = Left(strHY, Len(strHY) - 1)
If Len(strXB) Then strSQL = strSQL & " AND 性别 IN(" & strXB & ")"
If Len(strHY) Then strSQL = strSQL & " AND 婚姻 IN(" & strHY & ")"
Debug.Print strSQL
Me.患者资料查询子窗体.Form.RecordSource = strSQL
End Function作者: wang1950317 时间: 2007-9-3 15:15
huang大师源码实例,顶!如有库示例则更好了!谢谢!作者: huanghai 时间: 2007-9-3 18:19
例子下载补上了。