Undo record problem

N

Natalie

I have a form that inputs data into a table. I have 3 click buttons. One Adds
the Record to the table (Goes to next record), another Clears the form(Undo
the Record) and I have a third that closes the form. If there is no text
entered, form closes. If there is text typed, and then form is closed, the
text still gets added to the table. Solution to stop that, I had the
Close_Click() Undo the Record and then close the form. But now, if I add a
record and then close the form, I get a message asking me if I'm sure I want
to delete the record since that's what the Undo Record would do. I can click
no, so it won't delete the record, but I want to prevent this message from
coming up at all. Any suggestions?
 
B

Bryan in Bakersfield

Did you use VB or a macro for your close event? Either way you just need to
use the SetWarnings action.

If you used VB (good job), then you would add the line

DoCmd.SetWarnings False

to turn off warnings before the commands that delete the record

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

Then turn the warnings back on with

DoCmd.SetWarnings True

If you used a macro, same idea - just right-click on the first row and
Insert Row to add the SetWarning action and set it to No. Then add another
action at the end of the actions and SetWarning to Yes.

Always remember to turn Warnings back on, otherwise most warning messages
will be disabled - even while editing (problematic on several occasions).
 
J

John Nurick

This has been answered in another group.

I have a form that inputs data into a table. I have 3 click buttons. One Adds
the Record to the table (Goes to next record), another Clears the form(Undo
the Record) and I have a third that closes the form. If there is no text
entered, form closes. If there is text typed, and then form is closed, the
text still gets added to the table. Solution to stop that, I had the
Close_Click() Undo the Record and then close the form. But now, if I add a
record and then close the form, I get a message asking me if I'm sure I want
to delete the record since that's what the Undo Record would do. I can click
no, so it won't delete the record, but I want to prevent this message from
coming up at all. Any suggestions?
 

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

Top