我用了两个对象 总是包这样的错 要怎么写呢 我是小白 网上的内容看不懂 现在也没太多时间去系统的学习 求指教
Private Sub Command234_Click()
Set rst = New ADODB.Recordset
Set rst1 = New ADODB.Recordset
strSQL = "select 姓名 from 售后订单 where 选择=true and 售后完结=false"
rst1.Open strSQL, CurrentProject.Connection, adOpenKeyset, adLockOptimistic
If rst1.RecordCount > 1 Then
MsgBox "您不能选择没有售后没处理完的订单进行终结"
rst1.Close
Set rst1 = Nothing
Exit Sub
End If
rst1.Close
Set rst1 = Nothing
strSQL = "select 姓名 from 售后订单 where 选择=true"
rst.Open strSQL, CurrentProject.Connection, adOpenKeyset, adLockOptimistic '
这里报错错误'91':对象变量或With块变量未设置
If rst.EOF Then
MsgBox "您未选择数据进行操作"
rst.Close
Set rst = Nothing
Exit Sub
End If
rst.Close
Set rst = Nothing
num = rst.RecordCount
For i = 0 To rst.RecordCount - 1
msg = msg & "[" & rst.Fields(0) & "]"
rst.MoveNext
Next
' MsgBox msg
rst.Close
Set rst = Nothing
mya = MsgBox("您确定要终结以下" & num & "个人的订单吗?" & Chr(13) & Chr(10) & msg, 1 + 64, "警告!!!")
If mya = 1 Then
Dim sql As String
Dim sql1 As String
'str = "insert into 销售记录 (销售记录.供应商) values ('" & Me.供应商 & "')"
'MsgBox Format(Now, "yyyy-mm-dd")
sql = "update 销售记录 set 销售记录.订单状态=true ,销售记录.完结时间='" & Format(Now, "yyyy-mm-dd") & "' where 销售记录.选择=true"
sql1 = "update 售后订单 set 售后订单.订单状态=true where 销售记录.选择=true"
'MsgBox str
Call opensql(sql)
Call opensql(sql1)
Call czxz
Me.[销售记录查询1].Requery
End If
End Sub