Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

before update & subforms

Status
Not open for further replies.

jgoodman00

Programmer
Jan 23, 2001
1,510
0
0
I have written a sub to run on the before update event of a form in order to produce a history table of changes made to the data. This works perfectly in theory, but it falls down badly when a subform is introduced. As soon as the focus switches to the subform, it will register the changes & create a history entry. In the case of my db, it then switches to another subform & then back to the main table. By the time you have actually edited the record & moved onto the next record, it has saved at least 2 entries into the history table. Therefore, is there any way to surpress this function so that it only runs upon record-change. I am thinking that attaching the code to the 'on lost focus' event of the last control on the form, but i get the feeling it will then save a copy of the updated data, not the existing......


Any suggestions???? James Goodman
j.goodman00@btinternet.com
 
James,

I ran into the same problem before. The simplest solution is to create s "Save" button to activiate the sub you wrote. In this way, you let users decide when the record is updated.

This solution is not automatic to users, but intuitive. What do you think?

Seaport
 
I understand the idea, but i would have thought that as soon as you switch to the subform, it triggers the save event automatically, thus updating the source table. Therefore any history routine which then runs would surely save the new record, not the existing one?? James Goodman
j.goodman00@btinternet.com
 
As an update on that, I am wondering if it is possible to let the routine run, but store the variables temporarily. Then when the end of the form (mainform) is reached, trigger the 'ask to save' sub, along with the history update sub.....

Has anyone ever tried this? I see it being quite a lot of work, but in theory it should be possible.... James Goodman
j.goodman00@btinternet.com
 
It is a good idea theoretically. However, it is not feasible for me, at least. I have more than a dozen data entry forms in the database. Most of them have subforms. I can not implement this idea to all of them.

Access just cannot differentiate two situations of saving records: going to the subform and all other actions. This causes all the troubles we have.

Maybe you can think about unbound data entry forms. However, there are also lots of programming to do.

Seaport
 
yes, that is the way i am thinking of doing it....using unbound controls, & storing values temporarily before appending the whole lot to the table...i see it being highly problematical though James Goodman
j.goodman00@btinternet.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top