If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
do not save data on subForm
I have form which contains a subform. I placed code in the main form to not
save the information, if the user clicks on a "Close without Saving" button. If the subform contains data, the record is saved anyway. How can I drop the subform data if the user click on the "Close without Saving" button? Code in my main form: If Me.Dirty Then DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70 DoCmd.Close |
#2
|
|||
|
|||
do not save data on subForm
hi dsc2bjn,
it's more tricky with a subform. The way access works is to save any data in the subform as soon as the user clicks out of the subform onto the main form or any control on the main form. You could set the subform's data property to set allow edits, allow deletions, allow additions and data entry to No. This would prevent the user making any changes to the data in the subform. Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia "dsc2bjn" wrote in message ... I have form which contains a subform. I placed code in the main form to not save the information, if the user clicks on a "Close without Saving" button. If the subform contains data, the record is saved anyway. How can I drop the subform data if the user click on the "Close without Saving" button? Code in my main form: If Me.Dirty Then DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70 DoCmd.Close |
#3
|
|||
|
|||
do not save data on subForm
If I do as you suggest, the user wouldn't be able to enter any new
(subform)records or update any (subform) records. My gut is telling me to allow the data to be written to the (subform) data table, and add a query command that on dirty for the main form would delete the children records. I was hoping for a simple solution. "Jeanette Cunningham" wrote: hi dsc2bjn, it's more tricky with a subform. The way access works is to save any data in the subform as soon as the user clicks out of the subform onto the main form or any control on the main form. You could set the subform's data property to set allow edits, allow deletions, allow additions and data entry to No. This would prevent the user making any changes to the data in the subform. Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia "dsc2bjn" wrote in message ... I have form which contains a subform. I placed code in the main form to not save the information, if the user clicks on a "Close without Saving" button. If the subform contains data, the record is saved anyway. How can I drop the subform data if the user click on the "Close without Saving" button? Code in my main form: If Me.Dirty Then DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70 DoCmd.Close |
#4
|
|||
|
|||
do not save data on subForm
dsc2bjn wrote:
If I do as you suggest, the user wouldn't be able to enter any new (subform)records or update any (subform) records. My gut is telling me to allow the data to be written to the (subform) data table, and add a query command that on dirty for the main form would delete the children records. I was hoping for a simple solution. Let both forms save as Access is designed to work and replace your "close without saving" code with code that deletes the main record. If you have your relationships set up properly that will also delete the child record(s). -- Rick Brandt, Microsoft Access MVP Email (as appropriate) to... RBrandt at Hunter dot com |
#5
|
|||
|
|||
do not save data on subForm
Deleting the parent and children records works for new entries to the database.
I now need to be able to dump the form and subform changes, if the user changes their mind on exisiting records. I want to keep the data that was in the tables before they started editing the record. "Rick Brandt" wrote: dsc2bjn wrote: If I do as you suggest, the user wouldn't be able to enter any new (subform)records or update any (subform) records. My gut is telling me to allow the data to be written to the (subform) data table, and add a query command that on dirty for the main form would delete the children records. I was hoping for a simple solution. Let both forms save as Access is designed to work and replace your "close without saving" code with code that deletes the main record. If you have your relationships set up properly that will also delete the child record(s). -- Rick Brandt, Microsoft Access MVP Email (as appropriate) to... RBrandt at Hunter dot com |
#6
|
|||
|
|||
do not save data on subForm
"dsc2bjn" wrote in message
... Deleting the parent and children records works for new entries to the database. I now need to be able to dump the form and subform changes, if the user changes their mind on exisiting records. I want to keep the data that was in the tables before they started editing the record. On the form's (and the subform both) Before Update event allow the user to cancel the update: (from the help file): Private Sub Form_BeforeUpdate(Cancel As Integer) Me.Undo End Sub [It's a bit more involved than that, but I think you'll get the idea, since you already have the delete new record concept.] The thing is, you have to catch a 'cancel' BEFORE the user changes the focus from form to subform or vicea versa. -- Clif "Rick Brandt" wrote: dsc2bjn wrote: If I do as you suggest, the user wouldn't be able to enter any new (subform)records or update any (subform) records. My gut is telling me to allow the data to be written to the (subform) data table, and add a query command that on dirty for the main form would delete the children records. I was hoping for a simple solution. Let both forms save as Access is designed to work and replace your "close without saving" code with code that deletes the main record. If you have your relationships set up properly that will also delete the child record(s). -- Rick Brandt, Microsoft Access MVP Email (as appropriate) to... RBrandt at Hunter dot com -- Clif Still learning Access 2003 |
Thread Tools | |
Display Modes | |
|
|