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

Problem with Procedure Events

Status
Not open for further replies.

RonMcNatt

Technical User
May 22, 2002
32
US
I have a Procedure event which calls other sub events. One to FTP a file, one to unzip a file, one to append the unzipped files to external tables.

These three sub procedures (FTP,Unzip,Append) are called inside of a loop which steps through a record set. Once the loop is finished 25 files will have been FTP'ed, Unziped, and Appended.

It seems like Access is not waiting for one sub procedure to finish before it calls the next one. Every time I run this loop one or two files will be skipped (not always the same files). I thought Access hands control over to the sub procedure, which executes and then hands control back to the calling procedure when it done.

Is there any way to make sure the sub procedure is finished before the calling procedure conintues?
 
Hi Ron,

I've been CONVINCED in the past that this has been happening, but be sure that it isn't.

To be sure, place a 'delay' sub between each call.

e.g. for x = 1 to 20000000
next

Another way (to make absolutely sure) is place a msgbox in between each call (with OK to click to continue to next call).

If your prob disappears with the msgbox, then use the 'delay' for your app.

Don't think this is the answer for your app, hopefully someone else has.

Regards,

Darrylle

"Never argue with an idiot, he'll bring you down to his level - then beat you with experience."
 
If your main routine is written something like this:
Code:
    For i = 0 to 24
        FTPTheFile FileNames(i)
        UnzipTheFile FileNames(i)
        AppendTheFile FileNames(i)
    Next i
then you can be sure that the subroutines are executing serially. The only way there could be any overlap in execution is if the main routine were independently called from two separate events--such as a Start button being clicked on each of two forms, or two form Timer events going off.

I believe you're really observing the problem you describe, but it must be coming from something else. Why not show us the code and let us take a look?

(Just as a hunch, I wonder if you're using Dir() to look for files in the current directory, or in another one in which files are actively being created or deleted. I'm not sure how stable Dir() is when the directory contents are dynamically changing.) Rick Sprague
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top