A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

do not save data on subForm



 
 
Thread Tools Display Modes
  #1  
Old August 27th, 2008, 04:07 PM posted to microsoft.public.access.forms
dsc2bjn
external usenet poster
 
Posts: 94
Default 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  
Old August 27th, 2008, 10:48 PM posted to microsoft.public.access.forms
Jeanette Cunningham
external usenet poster
 
Posts: 2,190
Default 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  
Old August 28th, 2008, 03:03 PM posted to microsoft.public.access.forms
dsc2bjn
external usenet poster
 
Posts: 94
Default 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  
Old August 29th, 2008, 01:16 AM posted to microsoft.public.access.forms
Rick Brandt
external usenet poster
 
Posts: 4,354
Default 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  
Old August 29th, 2008, 01:44 PM posted to microsoft.public.access.forms
dsc2bjn
external usenet poster
 
Posts: 94
Default 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  
Old August 29th, 2008, 04:33 PM posted to microsoft.public.access.forms
Clif McIrvin[_2_]
external usenet poster
 
Posts: 629
Default 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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 07:21 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.