My Assistant
![]() ![]() |
|
|
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 |
|
|
|
Mar 31 2012, 12:42 PM
Post
#2
|
|
|
UtterAccess Ruler Posts: 1,090 |
If it is a bound form/controls then the save is automatically commited.
You can't use Transaction in that case. |
|
|
|
Mar 31 2012, 12:56 PM
Post
#3
|
|
|
UtterAccess Ruler Posts: 1,291 From: Kampala,Uganda The Pearl of Africa |
|
|
|
|
Mar 31 2012, 01:09 PM
Post
#4
|
|
|
UtterAccess Ruler Posts: 1,090 |
If you swith from Main form to subform or vice versa, changes are committed automatically, on which ever form has lost it focus.
|
|
|
|
Mar 31 2012, 01:58 PM
Post
#5
|
|
|
UtterAccess Ruler Posts: 1,291 From: Kampala,Uganda The Pearl of Africa |
It seems no subform event can help me pull off this...tried lostfocus...failed
Gave up Ronald |
|
|
|
Mar 31 2012, 04:35 PM
Post
#6
|
|
|
Rent-an-Admin Posts: 8,763 From: Banana Republic |
The only way to do this with a bound form is with a MySQL backend.
In all other cases, I'd just use a temporary local Access table that loads the records to be viewed and propagate back the changes. |
|
|
|
![]() ![]() |
|
Go to Top · Lo-Fi Version | Time is now: 21st May 2013 - 08:01 AM |