求助:对象变量或with块变量未设置错误
rss.EOF对象变量或with块变量未设置错误 ,基本程序如下:Private Sub cmdOK_Click()
On Error Resume Next
Select Case i
Case 1
If Combo1.Text = "" Then
MsgBox "车位号不能为空", , "系统提示"
Combo1.SetFocus
Exit Sub
End If
Dim rs As New ADODB.Recordset
Dim j As Integer
Dim k As Integer
k = 0
rs.Open "select * from 车位记录表", adoCon, adOpenStatic, adLockOptimistic
rs.MoveFirst
For j = 0 To rs.RecordCount
If rs.Fields("是否占用").Value = 1 Then
k = k + 1
End If
rs.MoveNext
Next j
rs.Close
If k > 4 Then
MsgBox "车位已满,请选择其他停车地点!", , "系统提示"
Else
Dim rss As New ADODB.Recordset
Set rss = adoCon.Execute("select * from 车位记录表 where 是否占用='" & Combo3.Text & "'and 使用日期=#" & DTPicker1.Value & "#")
If rss.EOF = False Then
MsgBox "此车位已经被占用,请选择其他车位!", , "系统提示"
DTPicker1 = Date
DTPicker1.SetFocus
rss.Close
Else
adoCon.Execute ("insert into 车位记录表 values ('" & Combo1 & "','" & DTPicker1.Value & "','" & Text1 & "','" & Text2 & "','" & Text3 & "','" & Text4.Text & "','" & Combo2 & "','" & Combo3 & "')")
MsgBox "记录添加成功!", , "系统提示"
Adodc1.Refresh
Adodc2.Refresh
End If
End If
Case 2
adoCon.Execute ("update 车位记录表 set 使用日期='" & DTPicker1.Value & "',车牌号='" & Text1 & "',车主姓名='" & Text2 & "',开始占用时间='" & Text3 & "',离开时间='" & Text4 & "', 车辆类别='" & Combo2 & "'是否占用='" & Combo3 & "' where 车位号='" & Combo1 & "'")
On Error Resume Next
Adodc1.Recordset.Update
MsgBox "记录修改成功!", , "系统提示"
Adodc1.Refresh
Adodc2.Refresh
End Select
Lockctl
cmdOK.Enabled = False: cmdCancel.Enabled = False
cmdAdd.Enabled = True: cmdUpdate.Enabled = True
cmdDelete.Enabled = True: cmdout.Enabled = True
End Sub