Simple Question: Repeat Module

mtairhead

Registered User.
Local time
Yesterday, 23:32
Joined
Oct 17, 2003
Messages
138
How do I make a module repeat? Currently, I have a command, which runs the module again.

Example:
" Call Generate_Reports_Based_on_Form2"
This code is actually in the module "Generate Reports Based on Form2"
Obviously, this only works from about 7,000 records, and then my computer "Runs out of Stack Space" due to the endlessly repeating modules upon modules.

Can I just make the module repeat? Will this not solve my memory problem?
I've searched this forum, and asked Mr. Clip-It...But I'm sure I just don't have the right vocabulary when I do.
 
M,

I don't think that calling the module over-and-over again is the answer.

Why can't the module traverse the data and generate the report?

Need more info ...

Wayne
 
Probably because I don't know how… This is the first VB script I've ever really designed, and it's mostly converted Macros.

The entire VB script plays out as follows:
(1) Opens a form with two fields: ID and Field1. ID is an auto-number, and Field1 are all various words. There are some 20K records.
(2) Runs the following Module (Below)
----
(1) Opens report, which is designed to only pick up and record records that have a similar value to Field1 in the previously mentions form above.
(2) Outputs the report as an MS Word file.
(3) Goes to next record in the form mentioned above
(4) Repeat

Currently, #4 is accomplished by simply calling the module to run again within the module...Which creates havoc on the mind, and I'm sure my computer.

Suggestions? The perfect solution would solve the error message I get at around the 7K record: “Out of Stack Space.”

Thanks
 
G’day mtaishead

Who knows what evil deeds macro’s do?

Terminology…one calls procedures, be they Subroutines or Functions not Modules.

“Out of Stack Space.” would indicate a call to a procedure without a return. Current position in code is being pushed to the stack but not pulled off again. This can happen if a procedure calls itself either directly or sometimes, rarely, by a Form’s OnCurrent event doing the same thing. (Sometimes called ‘Inadvertent Reentry” :D )

I really can’t help you without something substantial to look at i.e. need a small demo in A97 please. If table size is a problem, delete all records bar a couple, remove any sensitive data, compact, zip and post.

Regards,
Chris.
 
m,

You are recursively calling the module over and over again. Recursive code
is common for things like calculating factorials, traversing directories, etc.
However, they generally don't call themselves 20,000 times! And they have
a "terminal condition" where the function ceases to recurse and the calling
routines terminate normally. Your step #4 is the culprit here.

I think your function (subroutine, code) might only need to traverse a
recordset.

Like ChrisO said, a sample would help immensely.

Wayne
 
An extended response...

Even my slimmed-down version exceeds 100KB, the current limit for .zip files. The 1.4MB file is currently located on a geocities site…Sorry everyone, if bandwidth gets in your way. Feel free to email me at: mtairhead@yahoo.com if you need a copy.
(It’s just my seldom-used Yahoo address, so I feel comfortable posting it…)

http://www.geocities.com/mtairhead/Data.zip


The 30-second explanation is as follows:
There are two tables. One is called "Meta Tag" and holds data from various web sites (I've chosen whitehouse.gov for this example.) and the other, named "English Words," holds a collection of English words found somewhere on whitehouse.gov. The idea is to generate and export a report for each English word I have on my English word table. If a record in the "Meta Tag" table contains the word referenced in the "English Words" table, then the record is included in the report.

For example, if the word is Microsoft, then the file will contain several web pages with the word Microsoft either in the title, body text, or metatag keywords. The file name will become microsoft.html after it has been exported.

All I have to do is open and run the module named "Generate Pages" and all 21 words are used as criteria in reports and exported to the disk drive. (Normally they are exported to a directory on my computer, but for universality's sake, you'll need a disk in your A:\ drive...) The code works well with only 21 records, but 20K is a different story.

Does this help at all? Please tell me if I'm only confusing people...

Thanks,

Andrew

PS: I mean nothing politically by choosing whitehouse.gov...It just seemed the easiest...Cheers...
 

Users who are viewing this thread

Back
Top Bottom