能帮我看看代码哪里错了吗
我实现的功能是查询 通过选单选框 然后把数据放在datagrid中
可是提示我 错误 说无效的方法或数据成员
能帮我看看那里出问题了吗
Private Sub cmnquery_Click()
Dim StrSQL As String
StrSQL = "select * from rsxx where " '//给定义好的字符变量赋予SQL语句
'//判断单选框中时,判断姓名单选框选中时
If optname.Value = True Then
StrSQL = StrSQL & "员工姓名 = ' " & Trim(txygname.Text) & " ' "
'//判断单位单选框选中时
ElseIf optdanwei = True Then
StrSQL = StrSQL & "岗位 = ' " & Trim(txygdanwei.Text) & " ' "
'//判断岗位单选框选中时
ElseIf optgangwei = True Then
StrSQL = StrSQL & "岗位 = ' " & Trim(txyggwei.Text) & " ' "
'//判断学历单选框选中时
ElseIf optxueli = True Then
StrSQL = StrSQL & "学历 = ' " & Trim(txygxueli.Text) & " ' "
'//判断政治面貌单选框选中时
ElseIf optzzmm = True Then
StrSQL = StrSQL & "政治面貌 = ' " & Trim(txzzmm.Text) & " ' "
'//判断性别单选框选中时
ElseIf optsex = True Then
StrSQL = StrSQL & "性别 = ' " & Trim(txsex.Text) & " ' "
'//判断合同时间单选框选中时
ElseIf opthttime = True Then
StrSQL = StrSQL & "劳动合同日期 between # " & dtphetong1.Value & "# and # " & dtphetong2.Value & "# " & " "
If RsQRecord.State = adStateClosed Then
RsQRecord.Open StrSQL, DBCON, adOpenKeyset, adLockOptimistic, adCmdText
End If
Set dgrecord.DataSource = RsQRecord.DataSource
lblcount.Caption = RsQRecord.RecordCount '//将记录条数显示在标签上
dgrecord.Refresh '//刷新网格
RsQRecord.Close '//关闭记录集
txygname.Text = Empty '//请空文本框
txygdanwei.Text = Empty
txyggwei.Text = Empty
txygxueli.Text = Empty
txzzmm.Text = Empty
txsex.Text = Empty
Else
If RstQRecord.State = adStateClosed Then
RstQRecord.Open "rsxx ", DBCON, adOpenKeyset, adLockOptimistic, adCmdTable
End If
Set dgrecord.DataSource = RstQRecord.DataSource '//设置网格的数据源
lblcount.Caption = RstQRecord.RecordCount
dgrecord.Refresh '//刷新网格
RstQRecord.Close '//关闭记录集
txygname.Text = Empty '//请空文本框
txygdanwei.Text = Empty
txgangwei.Text = Empty
txxeuli.Text = Empty
txzzmm.Text = Empty
txsex.Text = Empty
End If
End Sub
Private Sub cmnreturn_Click()
Unload Me
End Sub
Private Sub DTPicker2_CallbackKeyDown(ByVal KeyCode As Integer, ByVal Shift As Integer, ByVal CallbackField As String, CallbackDate As Date)
End Sub
Private Sub Form_Load()
If RstQRecord.State = adStateOpen Then
RstQRecord.Close
End If
RstQRecord.Open "rsxx ", DBCON, adOpenKeyset, adLockPessimistic, adCmdTable
If RstQRecord.RecordCount > 0 Then '//如果记录集中有记录
dgrecord.DataSource = RstQRecord.DataSource '//设置网格的数据源
///////////////说上面的一句错 未找到方法或数据成员
Set CmbCode.RowSource = RstQRecord '//DATACOMBO中的数据等于记录集
CmbCode.BoundColumn = "员工编号 " '//绑定列
CmbCode.ListField = "员工编号 "
Else '//否则。清空
CmbCode.Text = " "
End If
End Sub
[解决办法]
dgrecord.DataSource = RstQRecord.DataSource '//设置网格的数据源
'对象变量赋值,使用Set语句
Set dgrecord.DataSource = RstQRecord '//设置网格的数据源