为什么我查询的结果 只能显示一次 在查询就不行
为什么我查询的结果 只能显示一次 在查询就不行
代码 如下
Dim StrSQL As String
StrSQL = "select * from rsxx where " '//给定义好的字符变量赋予SQL语句 "
'//判断单选框中时,判断姓名单选框选中时
If optname.Value = True Then
StrSQL = StrSQL & " 姓名 = ' " & Trim(txygname.Text) & " ' "
StrSQL = StrSQL & "劳动合同日期 between # " & dtphetong1.Value & "# and # " & dtphetong2.Value & "# " & " "
Else
MsgBox "请选择一个查询条件 ", vbExclamation + vbOKOnly, "查询失败 "
Exit Sub
End If
'//当单选框选中时
If RstQRecord.State = adStateClosed Then
RstQRecord.Open "rsxx ", DBCON, adOpenKeyset, adLockOptimistic, adCmdTable
End If
If RsQRecord.State = adStateClosed Then '//执行StrSQL中的
RsQRecord.Open StrSQL, DBCON, adOpenKeyset, adLockOptimistic, adCmdText
dgrecord.Refresh '//刷新网格
Set dgrecord.DataSource = RsQRecord.DataSource
lblcount.Caption = RsQRecord.RecordCount '//将记录条数显示在标签上
' RsQRecord.Close '//关闭记录集
txygname.Text = Empty '//请空文本框
txygdanwei.Text = Empty
txyggwei.Text = Empty
txygxueli.Text = Empty
txzzmm.Text = Empty
txsex.Text = Empty
End If
------解决方案--------------------
你调试一下那部分出问题:
当单选框选中时没有执行查询还是刷新网格
[解决办法]
StrSQL = StrSQL & " 姓名 = ' " & Trim(txygname.Text) & " ' "
//****************************************************
StrSQL = StrSQL & " AND "
//****************************************************
StrSQL = StrSQL & "劳动合同日期 between # " & dtphetong1.Value & "# and # " & dtphetong2.Value & "# " & " "