R
Ronnie
I have a form called fmhostrec which has a command button to allow edits.
The name of the command button is cmdlock which has the on click event below.
Private Sub cmdlock_Click()
Dim bLock As Boolean
DoCmd.GoToControl "HostRecName"
If Me.Dirty Then
Me.Dirty = False (RUNTIME ERROR)
End If
bLock = Not Me.AllowAdditions
Me.AllowAdditions = bLock
Me.AllowDeletions = bLock
Me.AllowEdits = bLock
Me.cmdlock.Caption = IIf(bLock, "&Lock", "Un&Lock")
End Sub
I also have on the form the following event
Private Sub Form_BeforeUpdate(Cancel As Integer)
If MsgBox("Save changes?", vbOKCancel) <> vbOK Then
Cancel = True
Me.Undo
MsgBox "Changes were not saved."
End If
End Sub
Everything works fine on this event except on thing. When I click the
cmdlock command button and then make changes, and then do not save the
changes I get a runtime error.
See above where runtime error points to. I got this code from looking at
previous messages from this board. I understand the Beforeupdate event. I
do not understand part of the cmdlock_Click() event so it is making it
difficult for me to troubleshoot. The bit I do not understand is block = not
Me.AllowAdditions.
Any help would be appreciated to debug this runtime error.
Thanks
Ronnie
The name of the command button is cmdlock which has the on click event below.
Private Sub cmdlock_Click()
Dim bLock As Boolean
DoCmd.GoToControl "HostRecName"
If Me.Dirty Then
Me.Dirty = False (RUNTIME ERROR)
End If
bLock = Not Me.AllowAdditions
Me.AllowAdditions = bLock
Me.AllowDeletions = bLock
Me.AllowEdits = bLock
Me.cmdlock.Caption = IIf(bLock, "&Lock", "Un&Lock")
End Sub
I also have on the form the following event
Private Sub Form_BeforeUpdate(Cancel As Integer)
If MsgBox("Save changes?", vbOKCancel) <> vbOK Then
Cancel = True
Me.Undo
MsgBox "Changes were not saved."
End If
End Sub
Everything works fine on this event except on thing. When I click the
cmdlock command button and then make changes, and then do not save the
changes I get a runtime error.
See above where runtime error points to. I got this code from looking at
previous messages from this board. I understand the Beforeupdate event. I
do not understand part of the cmdlock_Click() event so it is making it
difficult for me to troubleshoot. The bit I do not understand is block = not
Me.AllowAdditions.
Any help would be appreciated to debug this runtime error.
Thanks
Ronnie