Results 1 to 5 of 5
  1. #1
    Join Date
    Feb 2004
    Location
    Indiana, USA
    Posts
    79

    Red face Unanswered: Invalid Outside Procedure when running module

    I am trying to collate reports using the information from the knowledgebase
    ACC2000: Using Visual Basic Code to Collate and Print Two Reports

    I am using Access 2000.

    Seems to be fine if I just use 2 reports but need to include 3 more.

    When I enter ---
    ? CollateReports(1, "rptADLGrid 1- 15", "rptADLGrid 16-31", "rptContinenceTracking", "rptNsg ToiletingFlowSheet", "rptNsg RehabFlowSheet")
    into the Immediate window I get an error "Invalid Outside Procedure and it highlights -- For MyPageNum = 1 To NumPages

    Please help me figure out what is wrong

    The code in the module is:

    Option Compare Database
    Option Explicit
    '************************************************* ********************
    'NumPages is the number of pages in the largest report. If one report
    'has fewer pages, the DoCmd.PrintOut statement for the smaller report
    'runs correctly, and no additional pages are printed.
    '************************************************* ********************
    Dim MyPageNum As Integer

    'Set the page number loop and alternate printing the report pages.
    For MyPageNum = 1 To NumPages

    'NumPages is the number of pages to print.
    DoCmd.SelectObject acReport, "rptADLGrid 1-15", True
    DoCmd.PrintOut acPages, MyPageNum, MyPageNum
    DoCmd.SelectObject acReport, "rptADLGrid 16-31", True
    DoCmd.PrintOut acPages, MyPageNum, MyPageNum
    DoCmd.SelectObject acReport, "rptContinenceTracking", True
    DoCmd.PrintOut acPages, MyPageNum, MyPageNum
    DoCmd.SelectObject acReport, "rptNsgToiletingFlowSheet", True
    DoCmd.PrintOut acPages, MyPageNum, MyPageNum
    DoCmd.SelectObject acReport, "rptNsgRehabFlowSheet", True
    DoCmd.PrintOut acPages, MyPageNum, MyPageNum
    Next MyPageNum
    End Function

  2. #2
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    You never declare the function.
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  3. #3
    Join Date
    Feb 2004
    Location
    Indiana, USA
    Posts
    79

    Collate Reports based RecordID (Key)

    Thank You, That did the job. I never have been good at proofing my own work.

    Next question.

    Is there a way to collate reports based on a ResidentID.

    Example

    These reports are actually forms to document specific programs, each resident needs report 1 and 2 (easy so far) but not all residents need report 3, 4 or 5.

    John Q Public needs reports 1,2,3 and 5

    Susie Moondog needs reports 1,2 and 4.

    Medical records now sorts stack of reports and puts them together by Resident in a book for our staff to use.

  4. #4
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926

    Certain reports for certain users

    One way to approach this is to have a lookup table which has the user's loginID and the reportnames (see posts on getting the user's loginID). You could then write a function to get all the reports which need to be opened based on the lookup table and that user's loginID.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  5. #5
    Join Date
    Feb 2004
    Location
    Indiana, USA
    Posts
    79
    Thank You,

    I got busy researching the ID issue I forgot my manners. You have been a great help to me.

    Perplexed

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •