|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
我是一个access小白 只是写过JAVA 我在一个模块里面使用两个对象 总是报错【对象变量或with块变量】 查了资料看不懂 应该怎么写呢 大神
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 // 这里报错 对象变量或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 str As String
Dim str1 As String
'str = "insert into 销售记录 (销售记录.供应商) values ('" & Me.供应商 & "')"
'MsgBox Format(Now, "yyyy-mm-dd")
str = "update 销售记录 set 销售记录.订单状态=true ,销售记录.完结时间='" & Format(Now, "yyyy-mm-dd") & "' where 销售记录.选择=true"
str1 = "update 售后订单 set 售后订单.订单状态=true where 销售记录.选择=true"
'MsgBox str
Call opensql(str)
Call opensql(str1)
Call czxz
Me.[销售记录查询1].Requery
End If
End Sub
|
|