morglum007
Registered User.
- Local time
- Today, 08:07
- Joined
- Sep 28, 2009
- Messages
- 26
Avoiding access to save on close event [Solved]
Hi there,
Okay, here I am again with another access problem. I have some troubles when saving data in bound forms.
Here is the picture;
I got a bound form with some textbox/combobox/checkbox controls, that appears on blank once form loads in order to make user to fill 'em.
If everything goes ok, at the end user could push a button that will save records into data base with no problems.
I am using the cancel=true statement in each control's afterupdate event to avoid access to save if user does not allow it.
Here is the code of the update data base button, that is working properly:
Till here, no problem.
For a better front-end looking, and assuming users are not going to fill all fields, I added the close command with the red X right up in one corner (the usual one).
This automated command will obviosly close form, but will save data in entered fields, and thats something I want to avoid.
I have tried to clear all controls in the form's on close event, doing the me.undo trick, the cancel=true one, but no luck, data is still being saved.
I cannot also do the delete last record trick when closing because this form is used as edit/delete form with correspond control load, so data could be corrupted if I approach this way when loading in edit/delete mode.
I have read somewhere to load form as unbound, and to save data changing it to bound one. This will prevent the close button to save data if form is unbounded. A good approach, but how do I code it?.
Even more, if there are tons of fields, should this approach make me to change all fields properties in vba by hand?
I think I didnt missed anything.
Thanks for your patience and eventual reply
Morg
Hi there,
Okay, here I am again with another access problem. I have some troubles when saving data in bound forms.
Here is the picture;
I got a bound form with some textbox/combobox/checkbox controls, that appears on blank once form loads in order to make user to fill 'em.
If everything goes ok, at the end user could push a button that will save records into data base with no problems.
I am using the cancel=true statement in each control's afterupdate event to avoid access to save if user does not allow it.
Here is the code of the update data base button, that is working properly:
Code:
Private Sub updb_Click()
confirm = MsgBox("Data will be saved, Are you sure?", vbExclamation + vbYesNo, "Confirmation")
Select Case confirm
Case Is = 6
Cancel = False
Me.Dirty = False
Cancel = True
Me.Undo
DoCmd.GoToRecord , , acNewRec
MsgBox "Data saved", vbExclamation, "Operation completed"
Case Is = 7
Me.Undo
DoCmd.GoToRecord , , acNewRec
End Select
End Sub
Till here, no problem.
For a better front-end looking, and assuming users are not going to fill all fields, I added the close command with the red X right up in one corner (the usual one).
This automated command will obviosly close form, but will save data in entered fields, and thats something I want to avoid.
I have tried to clear all controls in the form's on close event, doing the me.undo trick, the cancel=true one, but no luck, data is still being saved.
I cannot also do the delete last record trick when closing because this form is used as edit/delete form with correspond control load, so data could be corrupted if I approach this way when loading in edit/delete mode.
I have read somewhere to load form as unbound, and to save data changing it to bound one. This will prevent the close button to save data if form is unbounded. A good approach, but how do I code it?.
Even more, if there are tons of fields, should this approach make me to change all fields properties in vba by hand?
I think I didnt missed anything.
Thanks for your patience and eventual reply
Morg
Last edited: