Buttons are a bit of a crutch, it's easy to get a form covered in them
but they are not very user-friendly. If the user is doing data entry
a button requires them to stop and use the mouse. We try to do it all
with code.
In this case, I would create a dialog box that pops up and asks the
user to confirm the entry with an OK/Cancel option. Try something
like this
----------- Code Start -----------------
Private Sub frmMyForm_BeforeUpdate(Cancel As Integer)
On Error GoTo Err_frmMyForm_Click
Dim Msg, Style, Title
' Define message......................
Msg = "Is this record complete for saving?" _
& vbCrLf & vbCr & "If the change is correct, press OK" _
& vbCrLf & vbCr & "If this is a mistake, press Cancel to undo
the change"
' Define buttons......................
Style = vbOKCancel + vbCritical + vbDefaultButton2
' Define title..........................
Title = "Confirm Save Record?"
Response = MsgBox(Msg, Style, Title)
If Response = vbOK Then '.......... User chose Yes.
GoTo ProceedWithUpdate '...........complete the change
Else '.......... User chose No.
Me.Undo '.......... Undo the change.
End If
ProceedWithUpdate:
Exit Sub
Err_frmMyForm_Click:
MsgBox Err.Description
Resume ProceedWithUpdate
End Sub
----------- Code End -------------------
Brett
I have a form on which I have a command button to add a new record. If a user
is in the middle of adding a record and decides not to pursue the new record,
how do I code to allow the user to dump the record without having to hit
escape? Perhaps a command button that says "cancel new record"...I wouldn't
want this button to delete any other records as the users are not allowed to
delete other records from this database. Thanks in advance.
Cheers,
Brett