From what I have read, disabling Access' autosave on a form can only be done via VBA. I don't fully understand the Dirty property, so am unsure just how to make this work.
All I am after is preventing a particular sub-form from saving/updating until a button is clicked. Otherwise I think it could potentially mess with the Before Update I am trying to cobble together.
The particular code I have thrown together so far that I am worried about messing up (by creating a lot of not needed entries) is:
For the record, I just threw this together and have not done any testing just yet.
All I am after is preventing a particular sub-form from saving/updating until a button is clicked. Otherwise I think it could potentially mess with the Before Update I am trying to cobble together.
The particular code I have thrown together so far that I am worried about messing up (by creating a lot of not needed entries) is:
Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim oCost As Long
Dim nCost As Long
Dim oQty As Long
Dim nQty As Long
Dim oPrice As Long
Dim nPrice As Long
Dim pID As Long
Dim tID As Long
Dim oGP As Long
Dim nGP As Long
Dim wrk As DAO.Workspace
Dim db As DAO.Database
Dim rs As DAO.Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("Select * from tblChangeHistory")
'old value and new entered value variables
oCost = Me.Price.OldValue
nCost = Me.Price.Value
oQty = Me.Quantity.OldValue
nQty = Me.Quantity.Value
oPrice = Me.Text28.OldValue
nPrice = Me.Text28.Value
oGP = Me.GP.OldValue
nGP = Me.GP.Value
'forms Project ID
pID = Me.ProjectID
'begin transaction so action can be rolled back if user cancels or process fails
wrk.BeginTrans
rs.AddNew
rs("ProjectID") = pjID
rs("BeforeChangeQty") = oQty
rs("AfterChangeQty") = nQty
rs("BeforeChangeCost") = oCost
rs("AfterChangeCost") = nCost
rs("BeforeChangePrice") = oPrice
rs("AfterChangePrice") = nPrice
rs("BeforeChangeGP") = oGP
rs("AfterChangeGP") = nGP
If MsgBox("Commit changes?", vbYesNo) = vbYes Then
rs.Update
wrk.CommitTrans
Set rs = Nothing
Set db = Nothing
Else
wrk.Rollback
MsgBox "Changes have been discarded", vbOKOnly
Set rs = Nothing
Set db = Nothing
End If
End Sub
For the record, I just threw this together and have not done any testing just yet.