문제

I am getting "Run-time error '3251': Operation is not supported for this type of object." when I am trying to use the "FindFirst" on my DAO RecordSet. Can someone explain to me what I am doing wrong for this not to search for the record. The variable I am using is returning the correct value for the search.

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
도움이 되었습니까?

해결책

Did you try opening the recordset as a dbOpenDynaset (default without the enum specified in the open statement) or dbOpenSnapshot instead? The documentation on the Microsoft MSDN site specifies it takes one of those two recordsets.

Locates the first record in a dynaset- or snapshot-type Recordset object that satisfies the specified criteria and makes that record the current record (Microsoft Access workspaces only).

Microsoft MSDN article on Recordset.FindFirst

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top