clearing and closing a form

  • Thread starter Thread starter Brandon P
  • Start date Start date
B

Brandon P

I have a form that contains a linked subform. It is being used as a data
entry screen. If someone begins typing into the form (either the form or the
subform) it inserts a record if they simply stop inputing the information and
close the form. I need a way to close the form and to not add any record that
may have been started.

So far I've tried the following:

1. I've turned off the "Close Button" to require the use of a command button
2. I've tried to use the DoCmd.RunCommand to use the menu option to delete
the record. I would set the focus on the subform, run the command and do the
same for the main form. The only problem if no record was added--I get an
error and it stops processing the code.

I tried to figure out how to test the subform and the form for a record and
then use the delete command, but have be unsuccessful at that.

Help would greatly be appreciated.

TIA,
:Brandon:
 
The *only* way to trap the save in a bound form is to use the BeforeUpdate
event procedure of the form.

Private Sub Form_BeforeUpdate(Cancel As Integer)
If Msgbox("Save?", vbYesNo, "Confirm") = vbNo Then
Cancel = True
Me.Undo
End If
End Sub
 
Back
Top