Best way to cancel out of a data entry form?

M

Mick

I want to put a 'cancel' button in a data entry form so that if a user
enters some data and then cancels it discards the data entered, if I do
a delete record:

DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70

It seems to work but prompts the user 'do you want to delete 1 record'
which scares them a little. Is there a way to modify this or use
another function to get it to cancel and discard without the prompt or
to change the prompt to 'are you sure you want to cancel'?

Thanks for any input!

Mick
 
J

J. Goddard

You can turn the warning off with:

Docmd.setwarnings off

Be sure to turn it back on, though - the setting is for the whole
application, and having warnings off might disable messages you DO want
the users to see.

The help on SetWarnings gives a good explanation.

John
 
P

Peter R. Fletcher

If your form is used only for data _entry_ - not for editing existing
records - this will do what you want it to (but see below). If
you/your users also use the form for editing, this sequence will
delete the entire existing record, when what you (presumably) want to
do is simply discard any _changes_ made to it.

I think that what you want is Me.Undo - this will revert the new
record to any defaults you have set and reverse any changes made to a
current but pre-existing record. You won't see any scary prompts if
you do things this way.

I want to put a 'cancel' button in a data entry form so that if a user
enters some data and then cancels it discards the data entered, if I do
a delete record:

DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70

It seems to work but prompts the user 'do you want to delete 1 record'
which scares them a little. Is there a way to modify this or use
another function to get it to cancel and discard without the prompt or
to change the prompt to 'are you sure you want to cancel'?

Thanks for any input!

Mick

Please respond to the Newsgroup, so that others may benefit from the exchange.
Peter R. Fletcher
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

delete record 3
close and do not save 2
Copy record/Refigure date + 7 days 4
Variable not defined 1
Duplicating a record 7
Delete Wizard Not Working 1
subform and cancel button? 8
do not save data on subForm 5

Top