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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SAME PROCEDURE RUNS SEVERAL TIMES

Status
Not open for further replies.

fsweb2002

Programmer
Apr 11, 2002
94
TR
Hi there
I have a form with subform with the following problem.
The code on ONCURRENT event for the SUBFORM is to run a procedure called CHECKDATECREATED

It is called only once within the code.

However when I open the form with a record on it, it runs the CHECKDATECREATED 3 times.

There is only 1 item on the subform.

The CHECKDATECREATED has a warning message box, which means it shows up 3 times, which is pretty annoying.

I have checked the code on the MAIN FORM and SUBFORM and the CHECKDATECREATED is only called ONCE (on the OnCUrrent event of the subform)

Any ideas???

Thanks in advance

 
Could you post the code?
Check if you call:
Requery
Refresh
GoToControl
GoToRecord

Dan
[pipe]
 
thanks for your reply

I have none of those (Requery,Refresh,GoToControl,GoToRecord) on the code for either the mainform or subform (apart from procedures within buttons which only run if we press those buttons...

I´d love to put the code BUT it is EXTREMELY LONG. I think you´ll get confused and you´ll give up !

Regards
 
I would try to run the code step by step and see what happens, when it happens and figure out why it happens...

Dan

[smile]
 
I think you would be suprised at the tenacity of some of the membes of these forums.

But on to more "productive" thoughts. The repeated calls are alost certainly caused by the shift of focus between hte main and sub form. Since the oncurrent event is initiated each time the subform receieves hte focus, the procedure runs on each occassion. You should look for references to either form or it's controls by (or from) the other.

And on a more general note, If you have " ... EXTREMELY LONG ... " code, you may want to think about re-structuring the process. One of the current major goals of programming design is to minimize the length of specific procedures - specifically to minimize the need to review copious quantities of irrlevant code in understanding a process. Another use of the technique could be to step through the code with FREQUENT references to the "Call Stack" to help in identifying which procedures are instantiating the additional calls to the supposedly errant routine.

MichaelRed
m.red@att.net

There is never time to do it right but there is always time to do it over
 
thanks for the positive comments.

I´ll re-check if I can change when the routine runs.
I wanted to make it run when the subform changes, so I thought of using the Oncurrent...

Regarding the LONG CODE, I mean it is long to put here on the forum (most people wouldn´t bother to look at it.
Note that there are over 40 fields between the mainform and subform, and I cannot avoid having so much code.
Obviously I could delete the unrelevant code so I could put the "relevant" code on this thread, but that´s far too much work !!!
My experience with code is quite recent, and I am sure there are better ways to set up the code, which I will follow once I learn more about Access!
On the meantime the application works fine, so I'll leave it.
Then I will change it to make more "professional" as I learn more and more...

Thanks for your inputs

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top