DoCmd.Close acForm, formName, acSaveNo always save a record?

G

Guest

I have an Access form that is mapping to a SQL Sever table. The form allows
users to enter data, and then click a button ADD or CANCEL. The form has a
text box ID that is mapping with the primary key ID of the table student. The
button ADD works OK, but the problem is the button CANCEL. If a user enters
an ID, and the user clicks the CANCEL button, the VBA 'DoCmd.Close acForm,
formName, acSaveNo' always save that record.

Please give me some suggestions?

Thank you.
 
R

Rick Brandt

Lang said:
I have an Access form that is mapping to a SQL Sever table. The form
allows users to enter data, and then click a button ADD or CANCEL.
The form has a text box ID that is mapping with the primary key ID of
the table student. The button ADD works OK, but the problem is the
button CANCEL. If a user enters an ID, and the user clicks the CANCEL
button, the VBA 'DoCmd.Close acForm, formName, acSaveNo' always save
that record.

Please give me some suggestions?

Thank you.

acSaveNo refers to *design changes made to the form*, not to data changes.
Bound forms always save data changes when you move to a different record or
close the form. You could use code to UNDO any changes in your cancel
button...

Me.Undo

....but you would also have to cancel updates that would occur when they
navigate or close the form. This can be done by cancelling the BeforeUpdate
event.

Total control over when saving occurs really goes against the way Access
works. If you really want that behavior you will have to do a bit of work
to achieve it.
 

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