How to control saving subform

  • Thread starter Celal Ozturk via AccessMonster.com
  • Start date
C

Celal Ozturk via AccessMonster.com

I've search a lot but can't seem to find and answer to the below.

I am doing an application for a journal. I have a form with only one
subform. The main form contains info of the member and sub contains the
subscription dates of that member.

The main form has "Save", "Undo" and "Close" butrtons. The save and undo
buttons are disabled by default and is enabled when the main or sub form
becomes "dirty". The close button just closes the form if Save and Undo
buttons are not enabled (thus borh forms are not dirty) and displayes a
message box if they are.

However, this does not work with the subform. If the subform becomes dirty,
it is saved by default whether or not the save button is clicked. Is there
a way to set this so that the changes on the subform are not "undo"ed but
also not saved when the subform loses focus to the main form??

I hope I could express myself and I am aware of the opinion to let Access
work as default but the client wants it like this.

Many thanks in advance for all your help

Celal
cozturk[AT]nova-trade.com
 
J

Jeff Boyce

Consider looking into the subform's BeforeUpdate event to offer a way to
cancel changes.
 
C

Celal Ozturk via AccessMonster.com

Many thanks for your reply. The thing is, I don't want to cancel the
changes. I want the changes in the subform saved only when the save button
on the main form is clicked, not before. Do you know if & how I could use
"NoSave" in such case???

Celal
 
J

Jeff Boyce

Not sure I follow. The main form is bound to one table, the sub-form is
bound to another (related) table. When the focus on your form leaves the
main form, it HAS been saved! If your focus has moved to the sub-form,
clicking on a button on the main form will move the focus back to the main
form and (attempt) to save the sub-form data.
 
C

Celal Ozturk via AccessMonster.com

The unload event of the main form has a vbYesNoCancel dialog if the form is
dirty. The dirty condition is determined by checking if the save and undo
buttons are enabled or not. So, even if you move to the subform and try to
close the window, the dialog will appear and if you press no the changes on
the main form are not saved. However, if you make changes on the subform,
they are saved which is what I want to prevent.

The main form is bound to a query and the subform is bound to a related
table. The relationship is on the autonum field subscriber_no.

Hope I could clarify.

Thanks a lot,

Celal
 
C

Celal Ozturk via AccessMonster.com

I could use a similar code for the subform's lost focus event, but then it
would pop up the message anytime you leave the subform. I only want that
when you try to close or unload the main window.
 
J

Jeff Boyce

Why are you allowing the subform to gain focus, if you don't want any
changes there?

Have you looked into the Enabled and Locked properties of the subform
control?
 
C

Celal Ozturk via AccessMonster.com

User should be able to make changes on the subform too but this must be
saved together with the main form only when the save button is clicked -
not by default.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top