主题:请求帮助
Dim rs As ADODB.Recordset
Dim SQL As String
Dim msg As String
Private Sub Form_Load()
Call LoadData
End Sub
Private Sub LoadData()
Dim strItem As String
Dim strWhere As String
strWhere = " where 用户类别='" & Trim(cbokind.Text)
strWhere = strWhere & "' and 用户ID= '" & txtUserIdQuery.Text & "'"
SQL = " select * from 用户信息表 " & strWhere & " order by 用户ID"
Set rs = SelectSQL(SQL, msg)
ListUser.Clear
If rs.RecordCount > 0 Then //出错行
Do While (Not rs.EOF) And (Not rs.BOF)
strItem = Trim(rs.Fields(0)) & ":" & Trim(rs.Fields(1))
ListUser.AddItem (strItem)
rs.MoveNext
Loop
rs.MoveFirst
ListUser.ListIndex = 0
Else
CmdAdd.Enabled = True
CmdModify.Enabled = False
CmdDelete.Enabled = False
CmdCancel.Enabled = False
CmdSave.Enabled = False
Exit Sub
End If
Call FixData
CmdAdd.Enabled = True
CmdModify.Enabled = True
CmdDelete.Enabled = True
CmdCancel.Enabled = False
CmdSave.Enabled = False
End Sub
这面的程序,为什么老是在If rs.RecordCount > 0 Then 处提示出错呢,提示内容是:对象变量或with块未定义。
但rs这个变量我确实已经定义过了。
Dim SQL As String
Dim msg As String
Private Sub Form_Load()
Call LoadData
End Sub
Private Sub LoadData()
Dim strItem As String
Dim strWhere As String
strWhere = " where 用户类别='" & Trim(cbokind.Text)
strWhere = strWhere & "' and 用户ID= '" & txtUserIdQuery.Text & "'"
SQL = " select * from 用户信息表 " & strWhere & " order by 用户ID"
Set rs = SelectSQL(SQL, msg)
ListUser.Clear
If rs.RecordCount > 0 Then //出错行
Do While (Not rs.EOF) And (Not rs.BOF)
strItem = Trim(rs.Fields(0)) & ":" & Trim(rs.Fields(1))
ListUser.AddItem (strItem)
rs.MoveNext
Loop
rs.MoveFirst
ListUser.ListIndex = 0
Else
CmdAdd.Enabled = True
CmdModify.Enabled = False
CmdDelete.Enabled = False
CmdCancel.Enabled = False
CmdSave.Enabled = False
Exit Sub
End If
Call FixData
CmdAdd.Enabled = True
CmdModify.Enabled = True
CmdDelete.Enabled = True
CmdCancel.Enabled = False
CmdSave.Enabled = False
End Sub
这面的程序,为什么老是在If rs.RecordCount > 0 Then 处提示出错呢,提示内容是:对象变量或with块未定义。
但rs这个变量我确实已经定义过了。