Run macro till EOF

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have creaded a command button to run the following to export my reports and
save them each with a name in one of the fields. It works but it comes up
with an error at the end because it tries to go to the next record and one
doesn't exist. I need it to either stop at the last record or stop when the
field is blank.

DoCmd.RunCommand acCmdRecordsGoToFirst
DoCmd.RunMacro "Macro4", 100

The following is the setup of Macro4:
OpenReport
Report name: Inventory
View: Print Preview
Filter Name:
Where Condidtion: [ItemID]=[Forms]![Reels]![ItemID]
Window Mode: Normal
OutputTo
Object Type: Report
Object Name: Inventory
Output Format: HTML
Ouput File: ="g:\web\test\" & [Reports]![Inventory]![ItemID] & ".html"
Auto Start: No
Template File:
Encoding: Unicode (UTF-8)
Close
Object Type: Report
Object name: Inventory
Save: Prompt
RunCommand
Command: RecordsGoToNext
 
Raven,

Where does the 100 come from? Can you try the equivalent of this...

Dim NumberOfRecords As Integer
NumberOfRecords = DCount("*","QueryThatYourFormIsBasedOn")
DoCmd.RunMacro "Macro4", NumberOfRecords
 
Back
Top