"Cancel" button when adding a new rec

octatyan

Registered User.
Local time
Today, 12:49
Joined
Jan 10, 2003
Messages
36
Hi, I'm having trouble with a CANCEL command button.

When a user is entering a new record on a form, they may decide to cancel it. But if no information is entered in any fields, the cancel button produces an error message. The CANCEL button only works if info is first entered into any field.

How do I make it so the CANCEL button works even if no info has been typed yet?
 
try this...

1. Right click on your cancel button.
2. Click on the "Other" Tab
3. Under Name Use "cmdCancel"
4. Click on the "Event" Tab
5. On Click > Type [e , it will say Event Procedure > Click on ...
6. Put the following code

'==================================
' Created by Jamil
'==================================
Private Sub cmdCancel_Click()
DoCmd.CancelEvent
'Replace "FormA" in the next line with actual form name
DoCmd.Close acForm, "FormA", acSaveNo
End Sub

Good Luck
Jamil
:)
 
I actually don't want the form to close, I would like the form to just move back to the last record.

Any suggestions on this?
 
If Me.Dirty = True Then
Me.Undo
Else
MsgBox "There is nothing to Undo"
End If
 

Users who are viewing this thread

Back
Top Bottom