UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome Guest ( Log In | Register )

> Want To Use Transactions On Mainform/subform Set Up    
 
   
Kamulegeya
post Mar 31 2012, 12:33 PM
Post #1

UtterAccess Ruler
Posts: 1,291
From: Kampala,Uganda The Pearl of Africa



Hello UA

I have main form with a continuous sub form

I want the user to be able to commit all edits once.

So i have this global constant in a module
CODE
Public blInTransaction As Boolean


in the subform dirty event i have

CODE
Private Sub Form_Dirty(Cancel As Integer)
'user starts an edit, and start a transaction if required
If blInTransaction = False Then
' if not in a transaction then start one
DBEngine.BeginTrans
End If
blInTransaction = True
End Su


In the open event of the subform i have
CODE
Private Sub Form_Open(Cancel As Integer)
Dim rs As DAO.Recordset
Set rs = Me.RecordsetClone
blInTransaction = False
End Sub



On the main form i have the save button

CODE
Private Sub cdmSave_Click()
If blInTransaction = True Then
If MsgBox("Do you want to commit all changes?", vbYesNo) = vbYes Then
DBEngine.CommitTrans dbForceOSFlush
Else
DBEngine.Rollback
End If
End If
End Sub


If i change record on subform, and click save, the message box appears, but it looks like the changes are already committed because clicking no does not undo the changes.


Anyway to make it work?


I am open to an alternative solution

Ronald
Go to the top of the page
 
+

Posts in this topic


Thank you for your support! Reply to this topicStart new topic

Jump To Forum:
 



RSS Go to Top  ·  Lo-Fi Version Time is now: 21st May 2013 - 11:57 AM