Update ID to another table



In my partial code below I am updateting two tables at the same time, What is
the code to pass the new Autonumber from the one table rec2 to the other
table rec? This is how my relationship is setup

Also notice the Truck ID in rec statement, This is from a combobox, How can
I get just the ID sent not the actual number? I have tried
Me!CmbTruckNumber.ID or TruckID as the field is called, I have a code in
place for the combobox to update new Truck number if not listed.

Set rec = dbLocal.OpenRecordset("LoadInfoTbl", dbOpenDynaset)
Set rec2 = dbLocal.OpenRecordset("EquationTbl", dbOpenDynaset)

With rec2
!Exspense = Me!TxtExspense
!PlantDiscount = Me!TxtPlantDiscount
!PurchasePrice = Me!TxtBoughtPrice
!HotPrice = Me!TxtHotPrice
!HaulCost = Me!TxtHaulCost
!Yield = Me!TxtYield

End With
With rec
!BuyDate = Me!TxtDate
!Weight = Me!TxtWeight
!Mileage = Me!TxtMileage
!Rate = Me!TxtRate
!BuyPrice = Me!TxtBuyPrice
!TruckID = Me!CmbTruckNumber
End With

Thank You



Mike Painter

I'm not sure when teh autonumber is assigned. It may be available as soon as
you add the first field info.
In that case
rec.othernumber = rec2.autonumberfield.
If that fails you will have to use a soevents and get it from teh last
Simply binding your tables to the form would do the same thing by using a
subform that only showed a single record.
Your combobox would notmally return the ID of the record as opposed to some
other value but I'm not sure I know exactly what you are asking.

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question