Preview multiple instances of dynamically altered report

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bgremill
    New Member
    • Jun 2010
    • 3

    Preview multiple instances of dynamically altered report

    Hi, all!

    I have a report with quite a few fields that are hidden and moved depending on if they are tracked by the user or not. The report is previewing and printing just fine. However, my user wants to be able to open the same report in preview mode for multiple wells selected from a list box. So, one report might have 20 fields visible, and the next might only have 15 fields visible. I can get it to print one right after the other, but it will only preview the last one selected. Any ideas on how I can get the report to preview one right after the other?

    Any help is appreciated!

    Thanks,
    Brandi
  • jimatqsi
    Moderator Top Contributor
    • Oct 2006
    • 1293

    #2
    Please show us the code you are using to launch the report(s) now. That way we'll have a common starting point for discussion.

    Thanks,
    Jim

    Comment

    • bgremill
      New Member
      • Jun 2010
      • 3

      #3
      I have a form where the user selects the desired report and enters any criteria into text boxes or selects from combo/list boxes. There is code that gets the name of the report and a function that creates the where clause. Here's the basic code for printing the report:

      'Print a separate report for each Well
      Set db = CurrentDb
      Set qdf = db.QueryDefs("q ryWells") ‘Active WellIDs
      strSQL = qdf.SQL

      Set rst = db.OpenRecordse t(strSQL, dbOpenDynaset)

      strNewWhere = ""

      With rst
      If .RecordCount <> 0 Then
      .MoveFirst
      Do Until .EOF
      strNewWhere = strWhere & " AND WellID = " & !WellID
      DoCmd.OpenRepor t strDocName, lngView, , strNewWhere
      .MoveNext
      Loop
      End If
      End With

      Set qdf = Nothing
      Set rst = Nothing
      Set db = Nothing

      Where:
      strDocName = “rptWellLog”
      strWhere = "ReadDate Between #5/1/10# And #5/9/10#"
      lngView = 0 ‘Print

      Thanks!

      Comment

      • jimatqsi
        Moderator Top Contributor
        • Oct 2006
        • 1293

        #4
        Shouldn't lngview be acPreview if you want to preview these reports? I don't see lngview being set, so I don't understand why they don't all behave the same way.

        Jim

        Comment

        • bgremill
          New Member
          • Jun 2010
          • 3

          #5
          Originally posted by jimatqsi
          Shouldn't lngview be acPreview if you want to preview these reports? I don't see lngview being set, so I don't understand why they don't all behave the same way.

          Jim
          This is all in a function, and when I call the function, I pass it lngView. It prints each one fine, but only previews the last one. I think it opens each one, but the user only sees the last one because each time it opens a new one, it replaces the one before it. Somehow I'm going to have to dynamically create a copy of the original report for each well and open each one right after each other. Does that make sense?

          Comment

          • jimatqsi
            Moderator Top Contributor
            • Oct 2006
            • 1293

            #6
            You could go right to .pdf files and specify they should be opened. That would do it, but it's not really a preview.

            Comment

            • FishVal
              Recognized Expert Specialist
              • Jun 2007
              • 2656

              #7
              You may instantiate the same report class (Reprt_<report name>) as multiple instances via global object variables.

              Example:

              Code:
              Dim col As New VBA.Collection
              
              
              Private Sub btn_Click()
                  
                  Dim rpt As Report_rpt
                  Set rpt = New Report_rpt
                  rpt.Visible = True
                  col.Add rpt
                  
              End Sub

              Comment

              Working...