Toine
10-04-2007, 11:48 PM
I use the following code on the subform, however when I change or add a record nothing is saved. I have a mainform with a ok (save and close), annuleer (cancel) and toepassen (save only) button. I want to be able to rollback the data on the mainform and userforms. What am I doing wrong??
Option Compare Database
Option Explicit
Private booldataGewijzigd As Boolean
Private Sub Form_BeforeUpdate(Cancel As Integer)
If booldataGewijzigd = False Then
booldataGewijzigd = True
DBEngine.BeginTrans
End If
End Sub
Private Sub Form_Load()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Set db = currentdb
Set rs = db.OpenRecordset("select subformtemptabel.* from subformtemptabel where subformid = " & Forms![mainformtabel].testID)
Set Me.Recordset = rs
End Sub
Public Sub toepassen()
DBEngine.CommitTrans
booldataGewijzigd = False
End Sub
Public Sub okannuleer()
If booldataGewijzigd Then
Select Case knpStatus
Case "ok"
DBEngine.CommitTrans
Case "annuleer"
DBEngine.Rollback
End Select
End If
End Sub
Option Compare Database
Option Explicit
Private booldataGewijzigd As Boolean
Private Sub Form_BeforeUpdate(Cancel As Integer)
If booldataGewijzigd = False Then
booldataGewijzigd = True
DBEngine.BeginTrans
End If
End Sub
Private Sub Form_Load()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Set db = currentdb
Set rs = db.OpenRecordset("select subformtemptabel.* from subformtemptabel where subformid = " & Forms![mainformtabel].testID)
Set Me.Recordset = rs
End Sub
Public Sub toepassen()
DBEngine.CommitTrans
booldataGewijzigd = False
End Sub
Public Sub okannuleer()
If booldataGewijzigd Then
Select Case knpStatus
Case "ok"
DBEngine.CommitTrans
Case "annuleer"
DBEngine.Rollback
End Select
End If
End Sub