How to check if subform is dirty? And how to update?

G

Guest

Here is my scenario:

I got a main form with a subform. I got an exit button on my main form. I
would like to prompt the user whether they want to save changes after editing
the subform before they exit. If they answer no, the subform will undo all
the changes.

I have thought of two solution. Solution 1 is when they click on exit, I
would check if the subform is dirty. However, I couldn't get this to work.
Solution 2 is when the subform lost focus, I would check if the subform is
dirty. This didn't work either.

Does anyone know a way I can get these to work? I would prefer a solution
similar to Solution 1 if its possible.
 
J

John Vinson

Here is my scenario:

I got a main form with a subform. I got an exit button on my main form. I
would like to prompt the user whether they want to save changes after editing
the subform before they exit. If they answer no, the subform will undo all
the changes.

I have thought of two solution. Solution 1 is when they click on exit, I
would check if the subform is dirty. However, I couldn't get this to work.
Solution 2 is when the subform lost focus, I would check if the subform is
dirty. This didn't work either.

Does anyone know a way I can get these to work? I would prefer a solution
similar to Solution 1 if its possible.

This isn't nearly as easy as it seems.

The current mainform record is saved to disk and cannot be undone
(except by running a Delete query) the instant the user sets focus to
any field in the subform. Similarly, each record in the subform is
saved to disk, and cannot be undone, once the user moves either to a
new record on the subform or to any control on the mainform.

If you really want this capability, you'll need some fairly elaborate
code. One way is to base the Form and Subform on "scratch" tables
which get emptied at the beginning of the user's session; you'ld have
code (perhaps in a mainform button click) to copy the data from the
scratch tables into the "real" table once the user has accepted it.

Another option is... train the users that when they are entering data
on the form, they are entering data into the table; and that once it's
entered, it's there. If they don't want it in the table, don't enter
it to start with!

John W. Vinson[MVP]
Join the online Access Chats
Tuesday 11am EDT - Thursday 3:30pm EDT
http://community.compuserve.com/msdevapps
 

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