Hi-
I'm attempting to write a module that uses and updates info from two tables and does the following:
Opens the recordset of a table called "tblstorein v"
If the Needed Field in the tblstoreinv table is null and is less than the DCOH field from the tbldcinv then:
Else If Needed from tblstoreinv is > DCOH from tbldcinv, then Shipped = 0.
The module would loop for every record.
Below is the code that I am using:
When I get to this line (Set Rs = db.OpenRecordse t(tblstoreinv)) , it says "Object Required." Any idea how to fix this and make it run correctly?
Thanks for any help you can give...
I'm attempting to write a module that uses and updates info from two tables and does the following:
Opens the recordset of a table called "tblstorein v"
If the Needed Field in the tblstoreinv table is null and is less than the DCOH field from the tbldcinv then:
The Shipped Field in the tblstoreinv table equals the Needed Field and the DCOH field from tbldcinv = DCOH - Shipped
Else If Needed from tblstoreinv is > DCOH from tbldcinv, then Shipped = 0.
The module would loop for every record.
Below is the code that I am using:
Code:
Public Sub Inventory() [B]Set Rs = db.OpenRecordset(tblstoreinv)[/B] db.OpenRecordset (tbldcinv) Rs.MoveLast iRecCount = Rs.RecordCount Rs.MoveFirst For x = 1 To iRecCount With Rs If .Needed Is Null And .Needed < [tbldcinv]![DCOH] Then .Needed = .Shipped [tbldcinv]![DCOH] = [tbldcinv]![DCOH] - .Shipped ElseIf .Needed Is Null And .Needed > [tbldcinv]![DCOH] Then .Shipped = 0 End If .MoveNext 'Next record and loop End With Next x End Sub
Thanks for any help you can give...
Comment