Hello,
I have found a thread about using transactions to save data inserted in a form that contains a subform but I could not make the code work.
So here is my problem:
I have a form "frmTest" bound to the table "tblTests" and a subform "sfrmSteps" bound to the table "tblSteps". The form and the subform are linked by the field "IDTest".
How do I make a save button and a cancel button that acts on the current record of the form and on the records in the subform linked to the main form's record ?
Here is (part of) the code I use:
--------------------------------------------------------
Option Compare Database
Option Explicit
Dim cnn1 As ADODB.Connection
--------------------------------------------------------
Private Sub Form_Load()
Set cnn1 = CurrentProject.Connection
cnn1.BeginTrans
End Sub
--------------------------------------------------------
Private Sub btnSave_Click()
cnn1.CommitTrans
End Sub
--------------------------------------------------------
Private Sub btnCancel_Click()
cnn1.RollbackTrans
End Sub
What's wrong ?
Thanks,
Alex
I have found a thread about using transactions to save data inserted in a form that contains a subform but I could not make the code work.
So here is my problem:
I have a form "frmTest" bound to the table "tblTests" and a subform "sfrmSteps" bound to the table "tblSteps". The form and the subform are linked by the field "IDTest".
How do I make a save button and a cancel button that acts on the current record of the form and on the records in the subform linked to the main form's record ?
Here is (part of) the code I use:
--------------------------------------------------------
Option Compare Database
Option Explicit
Dim cnn1 As ADODB.Connection
--------------------------------------------------------
Private Sub Form_Load()
Set cnn1 = CurrentProject.Connection
cnn1.BeginTrans
End Sub
--------------------------------------------------------
Private Sub btnSave_Click()
cnn1.CommitTrans
End Sub
--------------------------------------------------------
Private Sub btnCancel_Click()
cnn1.RollbackTrans
End Sub
What's wrong ?
Thanks,
Alex