Results 1 to 2 of 2
  1. #1
    markjkubicki's Avatar
    markjkubicki is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Jul 2010
    Location
    Fire Island Pines, NY
    Posts
    496

    public variable in report not being passed to the subreport (!?)

    (this may belong under programming?)

    I have a report with several layers of subreport



    on a 3rd tier subReport I had these lines of code

    at the top:
    Code:
    Option Compare Database
    Dim mdblNoteNumber_detail As Double
    at OnOpen
    Code:
    Private Sub Report_Open(Cancel As Integer)
        mdblNoteNumber_detail = 1
    End Sub
    at DetailPrint
    Code:
    Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
        txtInstallationNoteNumber = mdblNoteNumber_detail
        mdblNoteNumber_detail = mdblNoteNumber_detail + 1
    HOWEVER,
    Every time the report prints, the first record does not show a value for txtInstallationNoteNumber
    all of the subsequent records correctly do...

    I thought:
    move the variable definition to the top level report (declaring it public)
    Code:
    Option Compare Database
    Public mdblNoteNumber_detail As Double
    and in its report open.. I'd move the code
    Code:
    Private Sub Report_Open(Cancel As Integer)
        mdblNoteNumber_detail = 1
    End Sub
    yet when the subreport opens...
    it has no value for mdblNoteNumber_detail

    as always, any suggestions would be greatly appreciated in advance,
    m.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,816
    What exactly are you trying to accomplish? If you just want to generate a sequence number for each record, textbox RunningSum property can do that. This property is only available on report, not form.

    However, the following worked for me. No need for the Open event code
    Code:
    Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
        txtInstallationNoteNumber = mdblNoteNumber_detail + 1
        mdblNoteNumber_detail = mdblNoteNumber_detail + 1
    End Sub
    AFAIK, subforms and subreports load before their parents, which means nothing on the main form/report is available to the sub when it loads.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Replies: 1
    Last Post: 07-05-2016, 02:36 PM
  2. Replies: 5
    Last Post: 04-27-2015, 02:40 PM
  3. Replies: 1
    Last Post: 01-04-2014, 09:44 PM
  4. How to use global/public variable
    By mrbabji in forum Programming
    Replies: 7
    Last Post: 05-18-2013, 10:08 PM
  5. Replies: 7
    Last Post: 07-26-2012, 12:18 AM

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