B
bwion
I have a table that is in a one-to-one relationship with another table. I use
the one-to-one relationship to store the comments (memo data-type) of the
other table, so I can enforce record-level locking. For example:
tblTransactions:
TransactionID - 1
CustomerID
InventoryID
Quant
tblTransactionComments:
TransactionID - 1
TransactionComments
My question is how can I use DAO to save a users input on a form to these
tables? If the comment field were in the tblTransaction it would be something
like this:
Set rstWrite = dbs.OpenRecordset("tblTransaction", dbOpenDynaset)
rstWrite.AddNew
rstWrite!CustomerID = lngVar
rstWrite!InventoryID = lngVar2
rstWrite!Quant = intVar
rstWrite!Comments = Me.txtComments
rstWrite.Update
rstWrite = Nothing
Or something to that effect. But since I am dealing with a one-to-one
relationship with tblTransactionComments and storing the comments in that
table, I cannot run "rstWrite.Update" without throwing an error (because I am
enforcing referential integrity) because there isn't a matching record in the
tblTransactionComments. What would be the best and more efficient way to save
the information? Is there a way to save the TransactionID to the
tblTransactions and tblTransactionComments at the same time? Any help is
appreciated! Thanks.
Ben
the one-to-one relationship to store the comments (memo data-type) of the
other table, so I can enforce record-level locking. For example:
tblTransactions:
TransactionID - 1
CustomerID
InventoryID
Quant
tblTransactionComments:
TransactionID - 1
TransactionComments
My question is how can I use DAO to save a users input on a form to these
tables? If the comment field were in the tblTransaction it would be something
like this:
Set rstWrite = dbs.OpenRecordset("tblTransaction", dbOpenDynaset)
rstWrite.AddNew
rstWrite!CustomerID = lngVar
rstWrite!InventoryID = lngVar2
rstWrite!Quant = intVar
rstWrite!Comments = Me.txtComments
rstWrite.Update
rstWrite = Nothing
Or something to that effect. But since I am dealing with a one-to-one
relationship with tblTransactionComments and storing the comments in that
table, I cannot run "rstWrite.Update" without throwing an error (because I am
enforcing referential integrity) because there isn't a matching record in the
tblTransactionComments. What would be the best and more efficient way to save
the information? Is there a way to save the TransactionID to the
tblTransactions and tblTransactionComments at the same time? Any help is
appreciated! Thanks.
Ben