On Unload

V

Vina

Hello,

Can someone help me on how i should do this?

I have a main form that has a sub form.
I have a rule in the main form that when they close it it
will ask them to save if they maake some changes but if
they make changes in the subform the rule doesnt run. I
have declared a flag in the main form and thought that it
will apply to the subform, what should i do that my
subform will also see the variables in the main form and
if changes are mad it will run the ON UNLOAD rule in the
main form.

To summarize:

1)I need to know where should i declare a variable that
both main form and subform will be able to see/read it.
2) where should i put the On UNOAD rule that both will be
able to forms will detect it.

Thanks
Vina
 
L

Larry Linson

If your Forms are "bound", that is, have a RecordSource property for the
form indicating a Table, SQL statement, or Query and Control Source
properties for the controls indicating the Field to be displayed, then when
the main Form closes, it is too late to ask the user whether they want to
save the data in the Form embedded in the Subform Control -- it was already
saved, when you moved from the Subform back to the main Form. And, unless
you have done something (such as code in the BeforeUpdate event) to prevent
it, the data in the main Form will also automatically be saved when you
close it.

Were you under the impression that you had to save changed data explicitly?
Or, are you using unbound Forms?

Larry Linson
Microsoft Access MVP
 
V

Vina

My main form is from a table, i know that when they
change the data it automatically change the data in the
table what actually i was trying to do is when they close
the form that had changes is it would ask them if they
want to update the MAIN table (meaning another table that
has the data) the table that i have in the form is just a
snap shot depending on their selection and so they can
make changes and after they finally close it they have
the option to update the main table or not yet.

Any idea i appreciated.
 
L

Larry Linson

What you'll have to do depends on how you have created the temporary
("snapshot" is not a good term to use because in Access it indicates a way
of saving a report) table, what it contains, and how you have handled the
form/date in the subform control.

You may well need to create some variables to keep track of whether there
has been an update to the main form's data and also to the subform's data.

I've never encountered a situation where I needed to use a temporary table
in the manner you describe. Perhaps if you clarified what you are trying to
accomplish, someone might be able to suggest an alternative approach that
would accomplish the same purpose.

Larry Linson
Microsoft Access MVP
 

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