S
Simon Harris
Hi All,
I have two buttons on a form...
Button A is for exit and save. Onclick event does the following:
---------------------------------------------------------------
Private Sub AddAmendOrderSaveButton_Click()
On Error GoTo Err_AddAmendOrderSaveButton_Click
'Save the record, requery the customers view form, so our new record is
displayed
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
Forms![FRM_switchboard]![SUBFRM_view_orders].Requery
'Switch off Echo method to avoid seeing 'enter parameter value' box
(See MS KB Article 811860)
DoCmd.Echo False
DoCmd.Close acForm, "FRM_add_amend_order"
'Switch echo back on
DoCmd.Echo True
Exit_AddAmendOrderSaveButton_Click:
Exit Sub
Err_AddAmendOrderSaveButton_Click:
MsgBox Err.Description
Resume Exit_AddAmendOrderSaveButton_Click
End Sub
Button B is for exit with *no* save. Onclick event does the following
---------------------------------------------------------------------
Private Sub AddAmendOrderCloseButton_Click()
'User has clicked exit button, so close the form
ReturnValue = MsgBox("Are you sure you want to close with out saving?",
vbDefaultButton2 + vbQuestion + vbOKCancel, "Close job without saving - Are
you sure?")
Select Case ReturnValue
Case vbOK
'Switch off Echo method to avoid seeing 'enter parameter value' box
(See MS KB Article 811860)
DoCmd.Echo False
DoCmd.Close acForm, "FRM_add_amend_order"
'Switch echo back on
DoCmd.Echo True
Case vbCancel
End Select
End Sub
Changes made are always saved, whether button A or B are pressed. I suspect
this is something to do with the way I have opened the record, which is like
this:
Private Sub SUBFRM_view_customers_DblClick(Cancel As Integer)
'User double clicked the customers list
stDocName = "FRM_add_amend_customer"
stLinkCriteria = "[id]=" & Forms!FRM_switchboard!SUBFRM_view_customers
DoCmd.OpenForm stDocName, , , stLinkCriteria
End Sub
Can anyone advise, or point me in the right direction to how I go about
making a button, or changing my form so that the user can exit without
saving changes?
Kind regards,
Simon.
--
-
* Please reply to group for the benefit of all
* Found the answer to your own question? Post it!
* Get a useful reply to one of your posts?...post an answer to another one
* Search first, post later : http://www.google.co.uk/groups
* Want my email address? Ask me in a post...Cos2MuchSpamMakesUFat!
I have two buttons on a form...
Button A is for exit and save. Onclick event does the following:
---------------------------------------------------------------
Private Sub AddAmendOrderSaveButton_Click()
On Error GoTo Err_AddAmendOrderSaveButton_Click
'Save the record, requery the customers view form, so our new record is
displayed
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
Forms![FRM_switchboard]![SUBFRM_view_orders].Requery
'Switch off Echo method to avoid seeing 'enter parameter value' box
(See MS KB Article 811860)
DoCmd.Echo False
DoCmd.Close acForm, "FRM_add_amend_order"
'Switch echo back on
DoCmd.Echo True
Exit_AddAmendOrderSaveButton_Click:
Exit Sub
Err_AddAmendOrderSaveButton_Click:
MsgBox Err.Description
Resume Exit_AddAmendOrderSaveButton_Click
End Sub
Button B is for exit with *no* save. Onclick event does the following
---------------------------------------------------------------------
Private Sub AddAmendOrderCloseButton_Click()
'User has clicked exit button, so close the form
ReturnValue = MsgBox("Are you sure you want to close with out saving?",
vbDefaultButton2 + vbQuestion + vbOKCancel, "Close job without saving - Are
you sure?")
Select Case ReturnValue
Case vbOK
'Switch off Echo method to avoid seeing 'enter parameter value' box
(See MS KB Article 811860)
DoCmd.Echo False
DoCmd.Close acForm, "FRM_add_amend_order"
'Switch echo back on
DoCmd.Echo True
Case vbCancel
End Select
End Sub
Changes made are always saved, whether button A or B are pressed. I suspect
this is something to do with the way I have opened the record, which is like
this:
Private Sub SUBFRM_view_customers_DblClick(Cancel As Integer)
'User double clicked the customers list
stDocName = "FRM_add_amend_customer"
stLinkCriteria = "[id]=" & Forms!FRM_switchboard!SUBFRM_view_customers
DoCmd.OpenForm stDocName, , , stLinkCriteria
End Sub
Can anyone advise, or point me in the right direction to how I go about
making a button, or changing my form so that the user can exit without
saving changes?
Kind regards,
Simon.
--
-
* Please reply to group for the benefit of all
* Found the answer to your own question? Post it!
* Get a useful reply to one of your posts?...post an answer to another one
* Search first, post later : http://www.google.co.uk/groups
* Want my email address? Ask me in a post...Cos2MuchSpamMakesUFat!