By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,841 Members | 1,704 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,841 IT Pros & Developers. It's quick & easy.

Stopping data being written to a table

P: n/a
I have a form with two sub forms. The form is set to data entry. The
form is bound directly to a table I have two buttons at the bottom of
the screen. One button is named reject and one is named accept. I
would like the reject button to cancel the current entry being written
to the table and the accept button to save the entry to the table.

I have tried the form.undo command and DoCmd.RunCommand acCmdUndo but
if you click on one of the subform it doesn't seem to undo the changes
(the subforms are not used to input data and are purely used for
reference) and a record is added to the table. If you do not click on
the subform and click the reject button no entries are added to the
table.

Any suggestions would be greatly appreciated.

Dec 5 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Mark wrote:
I have a form with two sub forms. The form is set to data entry. The
form is bound directly to a table I have two buttons at the bottom of
the screen. One button is named reject and one is named accept. I
would like the reject button to cancel the current entry being written
to the table and the accept button to save the entry to the table.

I have tried the form.undo command and DoCmd.RunCommand acCmdUndo but
if you click on one of the subform it doesn't seem to undo the changes
(the subforms are not used to input data and are purely used for
reference) and a record is added to the table. If you do not click on
the subform and click the reject button no entries are added to the
table.

Any suggestions would be greatly appreciated.
Trying to control when Access saves a record is definitely swimming against
the current. Trying to do so when you have a form with subforms is pretty
much a non-starter.

I suggest you let Access save when it wants and provide a delete button.
--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com
Dec 5 '06 #2

P: n/a
On 5 Dec 2006 10:47:39 -0800, "Mark" <mb*******@gmail.comwrote:
>I have a form with two sub forms. The form is set to data entry. The
form is bound directly to a table I have two buttons at the bottom of
the screen. One button is named reject and one is named accept. I
would like the reject button to cancel the current entry being written
to the table and the accept button to save the entry to the table.

I have tried the form.undo command and DoCmd.RunCommand acCmdUndo but
if you click on one of the subform it doesn't seem to undo the changes
(the subforms are not used to input data and are purely used for
reference) and a record is added to the table. If you do not click on
the subform and click the reject button no entries are added to the
table.

Any suggestions would be greatly appreciated.
By clicking on the subform you are moving focus away from the main form. This is
a trigger for Access to save the record.

In this scenario the main record cannot be undone, it must be deleted.
Your cancel button will need something like.

If Me.NewRecord Then
Me.Undo
Else
CurrentDB().Execute "DELETE * FROM tblMyTable WHERE (MyID)=" & Me.MyID & ";"
End IF
Wayne Gillespie
Gosford NSW Australia
Dec 5 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.