committrans and RI
am 13.11.2007 20:02:21 von Arc
I'm having the strangest problem. Anyone ever have problems with committing
a transaction on writes that have referential integrity?
If I step through the code, it will commit the transaction fine. If I don't
put a break in the code, and let it run on it's own, I get:
"Err 3201: you cannot add or change a record because a related record is
required in the table 'PurchaseOrders'"
Basically in the code, I'm beginning a transaction, then writing a record to
the Purchase Orders table. Then I use these 2 lines to grab the new
PurchaseID:
rs2.Move 0, rs2.LastModified
NewPOID = rs2!PurchaseID
Finally, I add new entries to the related table for purchase detail items,
and use the newPOID as the id for the related record. Then I run a routine
that passes DB for the database, and re-calcs the p/o. Finally I commit the
transaction and without the break, I get the above error.
Ideas?
Re: committrans and RI
am 13.11.2007 23:57:30 von Allen Browne
Try moving to the new record by using the Bookmark of the recordset:
rs2.Bookmark = rs2.LastModified
--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"ARC" wrote in message
news:twm_i.9696$RR6.7156@newssvr22.news.prodigy.net...
> I'm having the strangest problem. Anyone ever have problems with
> committing a transaction on writes that have referential integrity?
>
> If I step through the code, it will commit the transaction fine. If I
> don't put a break in the code, and let it run on it's own, I get:
>
> "Err 3201: you cannot add or change a record because a related record is
> required in the table 'PurchaseOrders'"
>
> Basically in the code, I'm beginning a transaction, then writing a record
> to the Purchase Orders table. Then I use these 2 lines to grab the new
> PurchaseID:
>
> rs2.Move 0, rs2.LastModified
> NewPOID = rs2!PurchaseID
>
> Finally, I add new entries to the related table for purchase detail items,
> and use the newPOID as the id for the related record. Then I run a routine
> that passes DB for the database, and re-calcs the p/o. Finally I commit
> the transaction and without the break, I get the above error.