Link to home
Create AccountLog in
Avatar of Murray Brown
Murray BrownFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Access VBA Compile Error Sub or Function not defined

Hi

In my Access VBA code below, the Sub Form_BeforeUpdate code causes an error "Compile Error Sub or Function not defined"

Private blnSaved As Boolean

Private Sub Form_BeforeUpdate(Cancel As Integer)
    If blnSaved = False Then
        Cancel = True
        Me.Undo
        Cancel = False
    End If
End Sub

Private Sub Form_Current()
    blnSaved = False
End Sub

Private Sub btnOK_Click()
    blnSaved = True
    MsgBox "Changes saved!"
End Sub

Private Sub btnCancel_Click()
    DoCmd.Close
End Sub

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Jim Dettman (EE MVE)
Jim Dettman (EE MVE)
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
You should at least close one question before continuing it in a new question:

https://www.experts-exchange.com/questions/29080811/Access-VBA-Code-to-stop-data-saving-to-tables.html
Avatar of Murray Brown

ASKER

Thanks