Hi All
Access2002/2007
WunXPPro
In order to permit users to cancel their updates to records on Forms (subForms actually), I've adopted the DAO SQL Transaction technique: i.e. BeginTrans/RollBack/Commit etc.
I create a DAO recordset from the appropriate table and set the Form's recordset to it. Custom Save and Cancel buttons call CommitTrans or Rollback as reqd.
This works great for editing but I unable to add new records to the recordset??.
Here's how I open the rs:-
I then attempt to add a new record with:-
This fails at the AddNew with :-
3246 - This action was cancelled by an associated object.
I also tried with Me.Form.Recordset.AddNew..etc but his too fails with err3246.
I also tried with...
But this fails in the Current Event during the Requery with:-
'Operation Not Supported in Transactions'
Where am I going wrong please?? Thanks
P.S. I don't use the more normal BeforeUpdate / Cancel=True technique cos' all my custom buttons are on the Header of the mainForm and they can't be reached whilst there are oustanding updates on the subForm....
Access2002/2007
WunXPPro
In order to permit users to cancel their updates to records on Forms (subForms actually), I've adopted the DAO SQL Transaction technique: i.e. BeginTrans/RollBack/Commit etc.
I create a DAO recordset from the appropriate table and set the Form's recordset to it. Custom Save and Cancel buttons call CommitTrans or Rollback as reqd.
This works great for editing but I unable to add new records to the recordset??.
Here's how I open the rs:-
Code:
Private Edit_Wrk As Workspace
Private Edit_Db As Database
Private Edit_rstDAO As DAO.Recordset
'Set up Transaction resources
Set Edit_Wrk = Workspaces(0)
Set Edit_Db = CurrentDb
SQLLine = "SELECT * FROM MyTable"
Set Edit_rstDAO = Edit_Db.OpenRecordset(SQLLine, dbOpenDynaset, adLockPessimistic)
Set Me.Form.Recordset = Edit_rstDAO
Edit_Wrk.BeginTrans
I then attempt to add a new record with:-
Code:
Edit_rstDAO.AddNew
Edit_rstDAO!Date_Record_Added = "'" & Date & " " & Time & "'"
... blah blah..
Edit_rstDAO.Update
This fails at the AddNew with :-
3246 - This action was cancelled by an associated object.
I also tried with Me.Form.Recordset.AddNew..etc but his too fails with err3246.
I also tried with...
Code:
'Create New Record within Transction
SQLLine = "INSERT INTO MyTable.... blah blah"
Edit_Db.Execute SQLLine
'Query the RS to move to new record
Me.Form.Requery
But this fails in the Current Event during the Requery with:-
'Operation Not Supported in Transactions'
Where am I going wrong please?? Thanks
P.S. I don't use the more normal BeforeUpdate / Cancel=True technique cos' all my custom buttons are on the Header of the mainForm and they can't be reached whilst there are oustanding updates on the subForm....