G
Guest
I have a loop within a loop in a macro. It is working, however this causes an
error if it loops more than the allowed 20 times. I am not a coder, but may
have to do this with code. Can someone help with code? Or maybe I am just
doing this all wrong. Need to run report for each monthly period for each of
5 or more waste types.
Parameter inputs on a form:
FromDate = 1/1/06
ToDate = 3/30/07
Set ProcessedDates for 1st month (1/1/06 - 1/31/06)
Count records in WasteType and set RecCount
Set ProcessedCount = 1
Read first record in WasteType Table and set Waste Type
First loop:
Process and append data to table (for later export to Excel)
Run macro (Second Loop) to select next WasteType
If we have run all Waste types for the month, ( RecCount =ProcessedCount)
Increment the month, start and end dates
Set Waste Type to first record
And go to top of First Loop
Else go to next statement
If we have processed all requested months (ToDate = ProcessedDate)
Stop Macro
Second Loop:
If not at EOF (ProcessedCount = RecCount)
Read next record in Waste Type Table to get next WasteType
Increment ProcessedCount by 1
Go to First Loop
Else
Go to First Record in WasteType Table
Set ProcessCount = 1
Go to First Loop
Hope this makes sense. Thanks for any help.
error if it loops more than the allowed 20 times. I am not a coder, but may
have to do this with code. Can someone help with code? Or maybe I am just
doing this all wrong. Need to run report for each monthly period for each of
5 or more waste types.
Parameter inputs on a form:
FromDate = 1/1/06
ToDate = 3/30/07
Set ProcessedDates for 1st month (1/1/06 - 1/31/06)
Count records in WasteType and set RecCount
Set ProcessedCount = 1
Read first record in WasteType Table and set Waste Type
First loop:
Process and append data to table (for later export to Excel)
Run macro (Second Loop) to select next WasteType
If we have run all Waste types for the month, ( RecCount =ProcessedCount)
Increment the month, start and end dates
Set Waste Type to first record
And go to top of First Loop
Else go to next statement
If we have processed all requested months (ToDate = ProcessedDate)
Stop Macro
Second Loop:
If not at EOF (ProcessedCount = RecCount)
Read next record in Waste Type Table to get next WasteType
Increment ProcessedCount by 1
Go to First Loop
Else
Go to First Record in WasteType Table
Set ProcessCount = 1
Go to First Loop
Hope this makes sense. Thanks for any help.