Results 1 to 4 of 4
  1. #1
    bell is offline Advanced Beginner
    Windows 7 64bit Access 2002
    Join Date
    Feb 2015
    Posts
    37

    Post How to populate an Unbounded field in a Report when you go to open the Report

    Hi all,

    I have a working database with a form that allows the user to enter some info in.
    I have a report that has two unbounded fields (PrintPart1 and PrintSerial1, Report name is BlankSerialReport)
    On the form I have a button used to open the report



    My problem is setting up the BlankSerialReport button
    When clicked I want the button to print a number of BlankSerialReport's, all that have the same PrintPart1 field value and incrementing PrintSerial1 field values.

    So on my form I added three unbounded fields:
    Part --> To enter the PrintPart1 value
    FirstSerial --> To enter the starting PrintSerial1 value
    NumberBlanks --> To enter the number of BlankSerialReport's to be printed

    My event procedure for On Click
    Code:
    Private Sub Print_Blank_Reports_with_Serial_Number_Click()
    On Error GoTo Err_Print_Blank_Reports_with_Serial_Number_Click
    
    
        Dim stDocName As String
        Dim i As Integer
        Dim printSerialNumber As Integer
        
        stDocName = "BlankSerialReport"
        
        printSerialNumber = Me![FirstSerial]
        
        For i = 1 To Me![NumberBlanks]
            Reports!BlankSerialReport.Controls!PrintPart1 = Me!Part
            Reports!BlankSerialReport.Controls!PrintSerial1 = printSerialNumber
            DoCmd.OpenReport stDocName, acViewNormal
            printSerialNumber = printSerialNumber + 1
        Next
    
    
    Exit_Print_Blank_Reports_with_Serial_Num:
        Exit Sub
    
    
    Err_Print_Blank_Reports_with_Serial_Number_Click:
        MsgBox Err.Description
        Resume Exit_Print_Blank_Reports_with_Serial_Num
        
    End Sub
    The above code does not work, I keep getting "The report name 'BlankSerialReport' you entered is misspelled or refers to a report that isn't open or doesn't exist".

    I believe the problem is this code:
    Reports!BlankSerialReport.Controls!PrintPart1 = Me!Part
    Reports!BlankSerialReport.Controls!PrintSerial1 = printSerialNumber

    What is the correct way to set an unbounded field in a report before you open the report?

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Quote Originally Posted by bell View Post
    What is the correct way to set an unbounded field in a report before you open the report?
    In short, you can't; it has to be done after the report is open, or as it opens. You can use OpenArgs to pass the values:

    http://www.baldyweb.com/OpenArgs.htm

    or if the report will always be opened from that form, populated the controls in the report's open event getting the values from the form.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    bell is offline Advanced Beginner
    Windows 7 64bit Access 2002
    Join Date
    Feb 2015
    Posts
    37
    Thank you for that link! I was able to use OpenArgs to pass the info

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Happy to help!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 07-22-2014, 11:37 AM
  2. Replies: 4
    Last Post: 06-03-2014, 10:30 AM
  3. Replies: 7
    Last Post: 12-10-2013, 11:30 PM
  4. Replies: 5
    Last Post: 10-11-2012, 06:46 PM
  5. Replies: 5
    Last Post: 06-22-2011, 08:47 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums