I have a form which when opened to add a new record, and using the ondirty property, should update a table with a certain number of records. I have used the following code:
Code:
Private Sub Form_Dirty(Cancel As Integer)
DoCmd.SetWarnings False
If Me.NewRecord Then
For I = 1 To 14
DoCmd.RunSQL "INSERT INTO tbl_Transactions_detail_Data (TransactionID) VALUES (" & Me.tbl_Transactions_TransactionID & ")"
Next
DoCmd.SetWarnings True
Me.Requery
Else
End If
End Sub
The code works but not really, well:
if i am in an existing record, the code adds the required number of records to the other table (not suppose to happen)
If it is a new record the i get a runtime error 3134.
I am sure this is probably because the new record has yet to be saved and as a result the
Code:
Me.tbl_Transactions_TransactionID
value is not yet available.