大哥们!!!救救我呀,求你们了!!!
我在网上下了个数据查询的的代码,可改了以后就无法查询了数据库是我新建的,
运行提示:对象变量或with块变量未设置
大哥们呀,这是哪错了呀,怎么改呀!先谢谢了!
Private Sub cmdSave_Click()
Dim intCount As Integer
Dim sMeg As String
Dim mrc As ADODB.Recordset
Dim MsgText As String
For intCount = 0 To 1
If Trim(txtItem(intCount) & " ") = "" Then
Select Case intCount
Case 0
sMeg = "名称"
Case 1
sMeg = "绰号"
End Select
sMeg = sMeg & "不能为空!"
MsgBox sMeg, vbOKOnly + vbExclamation, "警告"
txtItem(intCount).SetFocus
Exit Sub
End If
Next intCount
If gintCmode = 1 Then
txtSQL = "select * from customers where xingming='" & Trim(txtItem(0)) & "'"
Set mrc = ExecuteSQL(txtSQL, MsgText)
If mrc.EOF = False Then 就是这个地方
MsgBox "已经存在此记录!", vbOKOnly + vbExclamation, "警告"
txtItem(0).SetFocus
Exit Sub
End If
mrc.Close
End If
If gintCmode = 2 Then
'先删除已有记录
txtSQL = "delete from customers where bianhao ='" & Trim(txtNo) & "'"
Set mrc = ExecuteSQL(txtSQL, MsgText)
End If
'再加入新记录
txtSQL = "select * from customers "
Set mrc = ExecuteSQL(txtSQL, MsgText)
mrc.AddNew
mrc.Fields(0) = txtNo
For intCount = 0 To 17
mrc.Fields(intCount + 1) = Trim(txtItem(intCount))
Next intCount
mrc.Update
mrc.Close
If gintCmode = 1 Then
For intCount = 0 To 17
txtItem(intCount) = ""
Next intCount
mblChange = False
MsgBox "添加信息成功!", vbOKOnly + vbExclamation, "添加信息"
Unload Me
If flagCedit Then
Unload frmCustomer
frmCustomer.txtSQL = "select * from customers"
frmCustomer.Show
End If
ElseIf gintCmode = 2 Then
Unload Me
If flagCedit Then
Unload frmCustomer
End If
frmCustomer.txtSQL = "select * from customers"
frmCustomer.Show
End If