save, close without saving - putting it together

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

My form is used to add records to a table. There are three fields, 2 text
box's and one list box. I have set the form property of data entry to yes so
the form opens with no record and there is no default data for any of the
fields. I have a 'save and close' command button and a 'cancel' button. I
have an event procedure for the forms before update event that brings up a
msgbox asking whether the record should be saved or not - vbyesno. I am left
with several questions:

it seems to me that my two command buttons are redundant because the before
update procedure does what i want both these buttons to do. So how should i
code my command buttons to work with the before update procedure?

Also, and there is several posts in this regard but again, i'm having
trouble integrating things - i want to add code to the save and close command
button that makes sure the forms fields are all dirty. - right now if i open
the form and click save and close it just closes.

thanks,

TDR
 
Trevor Ryhorchuk said:
My form is used to add records to a table. There are three fields, 2 text
box's and one list box. I have set the form property of data entry to yes so
the form opens with no record and there is no default data for any of the
fields. I have a 'save and close' command button and a 'cancel' button. I
have an event procedure for the forms before update event that brings up a
msgbox asking whether the record should be saved or not - vbyesno. I am left
with several questions:

it seems to me that my two command buttons are redundant because the before
update procedure does what i want both these buttons to do. So how should i
code my command buttons to work with the before update procedure?

Also, and there is several posts in this regard but again, i'm having
trouble integrating things - i want to add code to the save and close command
button that makes sure the forms fields are all dirty. - right now if i open
the form and click save and close it just closes.

thanks,

TDR
I would like to add a little more info now. my cancel button works fine
here is the code:
Private Sub CancelCmd_Click()
On Error GoTo Err_CancelCmd_Click

DoCmd.Close acForm, "Add Household Form", acSaveNo

Exit_CancelCmd_Click:
Exit Sub

Err_CancelCmd_Click:
MsgBox Err.Description
Resume Exit_CancelCmd_Click

End Sub
 
Back
Top