运行是这个出错 If rs.RecordCount = 0 Then,这是我的毕业设计,请高手救救! 10
OptionExplicitDimrsAsADODB.RecordsetDimSQLAsStringDimmsgAsStringDimIndexAsInteger'保存客...
Option Explicit
Dim rs As ADODB.Recordset
Dim SQL As String
Dim msg As String
Dim Index As Integer
'保存客户ID,使得当单击[修改客户]按钮的时候,能够将当前的教工信息加载到客户基本信息维护页面
Public empl_code As String
Private Sub Form_Load()
'初始化查询条件CboQuery
CboQuery.AddItem ("client_id")
CboQuery.AddItem ("client_name")
CboQuery.AddItem ("client_phone")
CboQuery.ListIndex = 0
Call LoadData
End Sub
Private Sub LoadData()
'装载数据
Dim colName As String
Dim colValue As String
Dim strWhere As String
'得到查询条件
colName = Trim(CboQuery.Text)
colValue = Trim(txtQuery.Text)
'构建条件
strWhere = "where " & colName & " like '%" & colValue & "%'"
Set rs = Nothing
'查询客户基本信息
SQL = "SELECT * FROM tblClient " & strWhere & " ORDER BY client_id "
Set rs = SelectSQL(SQL, msg)
Set Me.DataGrid1.DataSource = rs '在DataGrid显示查询的结果
DataGrid1.Refresh
If rs.RecordCount = 0 Then '如果不存在记录
'编辑控件可用性
ClientAdd.Enabled = True: ClientModify.Enabled = False: ClientDelete.Enabled = False
'移动控件不可用
For Index = 0 To 3
ClientMove(Index).Enabled = False
Next Index
Else
'编辑控件可用性
ClientAdd.Enabled = True: ClientModify.Enabled = True: ClientDelete.Enabled = True
'移动控件可用
For Index = 0 To 3
ClientMove(Index).Enabled = True
Next Index
End If
End Sub
提示的错误是rs.RecordCount =<对象变量或With块变量未设置
怎样检查?改了很久都改不了! 展开
Dim rs As ADODB.Recordset
Dim SQL As String
Dim msg As String
Dim Index As Integer
'保存客户ID,使得当单击[修改客户]按钮的时候,能够将当前的教工信息加载到客户基本信息维护页面
Public empl_code As String
Private Sub Form_Load()
'初始化查询条件CboQuery
CboQuery.AddItem ("client_id")
CboQuery.AddItem ("client_name")
CboQuery.AddItem ("client_phone")
CboQuery.ListIndex = 0
Call LoadData
End Sub
Private Sub LoadData()
'装载数据
Dim colName As String
Dim colValue As String
Dim strWhere As String
'得到查询条件
colName = Trim(CboQuery.Text)
colValue = Trim(txtQuery.Text)
'构建条件
strWhere = "where " & colName & " like '%" & colValue & "%'"
Set rs = Nothing
'查询客户基本信息
SQL = "SELECT * FROM tblClient " & strWhere & " ORDER BY client_id "
Set rs = SelectSQL(SQL, msg)
Set Me.DataGrid1.DataSource = rs '在DataGrid显示查询的结果
DataGrid1.Refresh
If rs.RecordCount = 0 Then '如果不存在记录
'编辑控件可用性
ClientAdd.Enabled = True: ClientModify.Enabled = False: ClientDelete.Enabled = False
'移动控件不可用
For Index = 0 To 3
ClientMove(Index).Enabled = False
Next Index
Else
'编辑控件可用性
ClientAdd.Enabled = True: ClientModify.Enabled = True: ClientDelete.Enabled = True
'移动控件可用
For Index = 0 To 3
ClientMove(Index).Enabled = True
Next Index
End If
End Sub
提示的错误是rs.RecordCount =<对象变量或With块变量未设置
怎样检查?改了很久都改不了! 展开
1个回答
展开全部
检查SQL = "SELECT * FROM tblClient " & strWhere & " ORDER BY client_id "
是否正确?
是否正确?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
浙江启扬智能科技有限公司
2023-06-12 广告
2023-06-12 广告
在嵌入式开发中,建立交叉开发环境可以提高开发效率和代码质量。以下是建立交叉开发环境的一些原因:1. 硬件资源限制:嵌入式系统的硬件资源,如处理器主频、内存容量等,相对于PC机来说较为有限。利用PC机进行开发可以利用更快的硬件设备,提高开发效...
点击进入详情页
本回答由浙江启扬智能科技有限公司提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询