使用 FindFirst 时出现 DAO RecordSet 错误 3251
Posted
技术标签:
【中文标题】使用 FindFirst 时出现 DAO RecordSet 错误 3251【英文标题】:DAO RecordSet error 3251 when using FindFirst 【发布时间】:2014-06-27 05:24:23 【问题描述】:当我尝试在我的 DAO RecordSet 上使用“FindFirst”时,我收到 “运行时错误 '3251':这种类型的对象不支持操作。”。有人可以向我解释我做错了什么,而不是搜索记录。我正在使用的变量正在返回正确的搜索值。
Private Sub ctrSend_Click()
Dim intI As Integer
Dim lst As ListBox
Dim varItem As Variant
Dim rst As DAO.Recordset
Dim rst2 As DAO.Recordset
Dim qtySum As Variant
Dim qtyDiff As Variant
Dim rowMax As Variant
Dim rowUpdate As Variant
Set lst = Me![lstShipping]
Set rst = CurrentDb.OpenRecordset("ShipInv", dbOpenTable)
Set rst2 = CurrentDb.OpenRecordset("Storage", dbOpenTable)
qtySum = 0
rowMax = 0
With lst
If .ItemsSelected.count = 0 Then Exit Sub
For Each varItem In .ItemsSelected
qtySum = qtySum + .Column(3, varItem)
Next
If Me.[ctrQtyProd] = qtySum Then
MsgBox "Qty Selected EQUALS Qty Being Shipped.", vbOKOnly, "Confirmation Message"
ElseIf Me.[ctrQtyProd] > qtySum Then
MsgBox "Qty Selected LESS THAN Qty Being Shipped, please select more Inventory.", vbOKOnly, "Confirmation Message"
Else
qtyDiff = qtySum - Me.[ctrQtyProd]
rowMax = lst.Column(3, lst.ItemsSelected.count)
rowUpdate = rowMax - qtyDiff
rst2.FindFirst "[BIN] = '" & lst.Column(0, lst.ItemsSelected.count) & "'"
rst2![QtyProd] = lst.Column(3, lst.ItemsSelected.count)
rst2.Update
rst2.Close
MsgBox "Storage Successfully Updated.", vbOKOnly, "Confirmation Message"
End If
End With
With lst
For Each varItem In .ItemsSelected
rst.AddNew
rst!Order = Me.[ctrSOrder]
rst!EntDate = Date
rst!ShipDate = Me.[ctrSDate]
rst!BIN = .Column(0, varItem)
rst!SKU = .Column(1, varItem)
rst!Lot = .Column(2, varItem)
rst!QtyProd = rowUpdate
rst.Update
Next
End With
rst.Close
Set rst = Nothing
Set rst2 = Nothing
MsgBox "Shipping List Successfully Updated.", vbOKOnly, "Confirmation Message"
End Sub
【问题讨论】:
【参考方案1】:您是否尝试将记录集作为 dbOpenDynaset(默认没有在 open 语句中指定的枚举)或 dbOpenSnapshot 来打开? Microsoft MSDN 站点上的文档指定它采用这两个记录集之一。
在满足指定条件的动态集或快照类型 Recordset 对象中找到第一条记录,并使该记录成为当前记录(仅限 Microsoft Access 工作区)。
Microsoft MSDN article on Recordset.FindFirst
【讨论】:
谢谢...帮助了。认为这很简单。 谢谢!使用.OpenRecordset("TableName", dbOpenDynaset)
像魅力一样工作以上是关于使用 FindFirst 时出现 DAO RecordSet 错误 3251的主要内容,如果未能解决你的问题,请参考以下文章
尝试执行 DAO 时出现 NullPointerException ... 无法初始化类 ..JavaReflectionManager
将 BigDecimal 转换为 Integer 时出现问题