大家能帮我看一下这段查询程序吗?不知道是什么原因,一运行strsql中显示的是一个select字符串.hzxx是数据库名
Private Sub find_Click()
Dim strSQL As String
Dim strCON(6) As String
Dim intCount As Integer
Dim I As Integer
inCount = 0
'获得所有的查询条件
'病历号查询
If blh.Text <> "" Then
If mhcz.Value = 1 Then
strCON(1) = "病历号 like '%" & blh.Text & "%'"
Else
strCON(1) = "病历号=' " & blh.Text & " ' "
End If
Else
strCON(1) = ""
End If
'姓名查询
If xm.Text <> "" Then
If mhcz.Value = 1 Then
strCON(2) = "姓名 like '%" & xm.Text & "%'"
Else
strCON(2) = "姓名=' " & xm.Text & " ' "
End If
Else
strCON(2) = ""
End If
'性别查询
If xb.Text <> "" Then
If mhcz.Value = 1 Then
strCON(3) = "性别 like '%" & xb.Text & "%'"
Else
strCON(3) = "性别=' " & xb.Text & " ' "
End If
Else
strCON(3) = ""
End If
'科别查询
If kb.Text <> "" Then
If mhcz.Value = 1 Then
strCON(4) = "科别 like '%" & kb.Text & "%'"
Else
strCON(4) = "科别=' " & kb.Text & " ' "
End If
Else
strCON(4) = ""
End If
'入院日期查询
If ryrq.Text <> "" Then
If mhcz.Value = 1 Then
strCON(5) = "入院日期 like '%" & ryrq.Text & "%'"
Else
strCON(5) = "入院日期=' " & ryrq.Text & " ' "
End If
Else
strCON(5) = ""
End If
'出院日期查询
If cyrq.Text <> "" Then
If mhcz.Value = 1 Then
strCON(6) = "出院日期 like '%" & cyrq.Text & "%'"
Else
strCON(6) = "出院日期=' " & cyrq.Text & " ' "
End If
Else
strCON(6) = ""
End If
If strCON(1) = "" And strCON(2) = "" And strCON(3) = "" And strCON(4) = "" And strCON(5) = "" And strCON(6) = "" Then
strSQL = "select * from hzxx"
Else
strSQL = "select * from hzxx where "
For I = 1 To 6
If strCON(I) <> "" Then
intCount = intCount + 1
If intCount = 1 Then
strSQL = strSQL + strCON(I)
Else
strSQL = strSQL + "and" + strCON(I)
End If
End If
Next
End If
Adodc1.RecordSource = hzxx.openrecordset(strSQL)
Adodc1.CursorLocation = adUseClient
Adodc1.CommandType = adCmdText
'Adodc1.RecordSource = strSQL
'Label7.Caption = Adodc1.RecordSource
'Adodc1.Refresh
End Sub
Private Sub Form_Load()
xb.AddItem ""
xb.AddItem "男"
xb.AddItem "女"
xb.Text = xb.List(0)
kb.AddItem ""
kb.AddItem "普外科"
kb.AddItem "骨科"
kb.AddItem "消化内科"
kb.AddItem "呼吸内科"
kb.AddItem "干部疗区"
kb.AddItem "妇科"
kb.AddItem "产科"
kb.AddItem "儿科"
kb.AddItem "泌尿外科"
kb.Text = kb.List(0)
Adodc1.RecordSource = ""
end sub