Cancel new record command

maikon

Oxxx|:::::::::::>
Local time
Today, 12:58
Joined
Jan 13, 2005
Messages
22
Folk,

I'm using the default command to add a new record in a table:

DoCmd.GoToRecord , , acNewRec

The question is: How I can cancel the new record inclusion on table? It's possible?

Thanx a lot,

Maikon
 
Place a command button (i.e. CmdDelete) on your form and add the following on the On_Click event of the command button

Code:
Dim Msg As String
Dim Title As String
Dim Result As Integer

Msg = "Are you sure you want to delete this Record?"
Title = "NameOfDatabase"
Result = MsgBox(Msg, 52, Title)

'User selects Yes
If Result = 6 Then

MsgBox "The record has been deleted.", vbInformation, "NameOfDatabase"
    
    DoCmd.SetWarnings False
    DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
    DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
    DoCmd.SetWarnings True

Else
    MsgBox "The record has NOT been deleted", vbInformation, "NameOfDatabase"

End If

HTH
 
Dave, what happen today to include a new record on table:

1. User click on the "Add" button.
2. The form is cleared by the command that I said before in the first post.
3. User enter the data as well he want.
4. User click on "Save" button to obviously save the new record on table.

What I need: before the step 4 I want that exists a button or a command to cancel the new record addiction, and when the user to click again on "Add" button, the new record autoincremented code be the same that was before the "Cancel" button was clicked.
 

Users who are viewing this thread

Back
Top Bottom