Results 1 to 9 of 9
  1. #1
    bgreg00 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2013
    Posts
    4

    Question Create 280 of the permutations of the same report for printing

    Hello,



    I'm using a bit of software developed in access for the statistical analysis of data. I am a new access user.

    There is a single report in the access database that I would like to run for 280 different data inputs. It is the same report, only the inputs change. If I did this manually, I would have to select each of the 280 data sets in a drop-down menu and then print off each one of the reports individually to a pdf creator.

    In my limited knowledge, it seems like I need a macro to both select the different data inputs and run the report over and over again. Somehow these reports would all have to be combined into a single printable report at the end.

    I realize this is a vague inquiry, but, honestly, any help to send me down the right path would be appreciated. Thank you!

    -Ben

  2. #2
    rzw0wr is offline I will always be a newbie
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2013
    Location
    Indiana
    Posts
    479
    Ben, Welcome to AccessForums.

    If you can upload your database we will take a look.

    It should be fairly easy to do but kinda rough to explain and do with out the database.

    Please remove any personal data from you database before uploading.

    Dale

  3. #3
    bgreg00 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2013
    Posts
    4
    Thank you for the response, Dale. I was hoping that there might just be an easy answer. I think the only way to see the access environment that I am working in would be to download the piece of access software that I am using. The software is called Maros 3.0 and it is a tool for evaluating trends in contaminated groundwater. It is freeware and can be downloaded here: http://www.gsi-net.com/en/software/free-software.html

    The Maros software comes with an example database "archive" file that can be loaded directly into the main software database to explore the functions of the software. The archive file is called "M3_ExampleArchive" and the main software is "MAROS v3".

    To load the archive file into MAROS, open MAROS v3 and select "Data Management and Site Details", select Import MAROS Archive File, browse to "M3_ExampleArchive", click retrieve, click data consolidation, click continue, click continue, click continue, click continue, click individual well analysis, click statistical trend analysis, click continue.

    Now you are at the form for "Mann-Kendall Plot". This is the form that I would have to manipulate manually to generate the individual reports. I would need to select a Well Name and a Chemical and then click "View Report". The report name in the database is rptMannKendallbyWellCOC. Can I batch this process so that a report is generated for all combinations of well names and chemicals? Also, can I make it so these reports are presented as one single report that I can print to pdf at one time.

    I understand if asking for this kind of specialized help might be asking for someone to go "above and beyond," but I would be appreciative of any help to start me down the right path.

    Thanks
    Ben

  4. #4
    rzw0wr is offline I will always be a newbie
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2013
    Location
    Indiana
    Posts
    479
    The Maros software comes with an example database "archive" file that can be loaded directly into the main software database to explore the functions of the software. The archive file is called "M3_ExampleArchive" and the main software is "MAROS v3".

    To load the archive file into MAROS, open MAROS v3 and select "Data Management and Site Details", select Import MAROS Archive File, browse to "M3_ExampleArchive", click retrieve, click data consolidation, click continue, click continue, click continue, click continue, click individual well analysis, click statistical trend analysis, click continue.
    I downloaded the Maros v3 Beta.
    I got seveal errors on Excel.
    I could not find Data Management and Site Details.

    Dale

  5. #5
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    I'm also looking at your problem. But I had to download the 2.2 version since I have A2K.

    I'm starting to get an idea of the process, but it is going to be a while...... on another project (and a couple of "honey do's")

  6. #6
    bgreg00 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2013
    Posts
    4
    Dale: You shouldn't have to use any of the excel files included in the software .zip file. I think all you should need to do is open the "Maros V3.accdb". I do remember that when I first opened the Maros V3 database it failed because of errors pertaining to security; I got rid of these errors by turning down the Access security settings. When this database opens (without errors) it should take to you directly to a Maros splash screen where it prompts for a User Name and Project Name. Enter whatever you want here. After that, it should take you directly to the main menu where you should see "Data Management and Site Details". From there you should be able to follow the directions that I gave you. You will need to load the the example Maros Archive File, which is called "M3_ExampleArchive.mdb". This file contains example analytical data and physical parameters. If I am repeating things that you already know, then your issue is something that I never encountered when configuring Maros on my machine, and I probably can't be too much more help.

    ssanfu: Thanks for taking a look. I just downloaded Maros 2.2 to see what you are working with. There are some slight differences. Unlike Maros 3, the example data that you will need to load into maros is an excel file "TutorialExampleData.xls". Unlike the Maros 3 example data, these data do not include site details (physical data), so you will need to make some up after you load the example data. You can do this in "step 2. Site Details" of the Main Menu screen. Basically type whatever you want into any of the boxes. Choose "Auto Event" when you get to the sample event screen. Assign all the wells as source or tail. Pick one chemical as your constituent of concern (COC). After that your site details should be all set for the Mann Kendall analysis. The Mann Kendall analysis is located in Step 3b of the main menu. The report I am trying to batch is generated from the Mann Kendall Plot form. I believe the report is called "Report_rptMannKendallbyWellCOC" in this version of Maros.

    Thank you both so much for looking into this!

    -Ben

  7. #7
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Ben,
    I don't understand the data or the forms... and I don't really want to study to get the data entered. But I think I have most of this worked out.

    I started with the report you want to print (as a PDF). I looked at the record source to see where the data is coming from. Then I found the form that had a button on it that opened the report and looked at the code to see what criteria/ parameters were needed.
    I added a "print all" button and added the code below.

    So....

    The following code allows you to choose where you want the PDF files to be saved.
    I created a new standard module ("GetFolderCode") and pasted in the following code:
    Code:
    Option Compare Database
    Option Explicit
    
    '************** Code Start **************
    'This code was originally written by Terry Kreft.
    'It is not to be altered or distributed,
    'except as part of an application.
    'You are free to use it in any application,
    'provided the copyright notice is left unchanged.
    '
    'Code courtesy of
    'Terry Kreft
    '
    'From >>  http://access.mvps.org/access/api/api0002.htm
    '
    
    Private Type BROWSEINFO
      hOwner As Long
      pidlRoot As Long
      pszDisplayName As String
      lpszTitle As String
      ulFlags As Long
      lpfn As Long
      lParam As Long
      iImage As Long
    End Type
    
    Private Declare Function SHGetPathFromIDList Lib "shell32.dll" Alias _
                "SHGetPathFromIDListA" (ByVal pidl As Long, _
                ByVal pszPath As String) As Long
                
    Private Declare Function SHBrowseForFolder Lib "shell32.dll" Alias _
                "SHBrowseForFolderA" (lpBrowseInfo As BROWSEINFO) _
                As Long
                
    Private Const BIF_RETURNONLYFSDIRS = &H1
    
    Public Function BrowseFolder(szDialogTitle As String) As String
      Dim X As Long, bi As BROWSEINFO, dwIList As Long
      Dim szPath As String, wPos As Integer
      
        With bi
            .hOwner = hWndAccessApp
            .lpszTitle = szDialogTitle
            .ulFlags = BIF_RETURNONLYFSDIRS
        End With
        
        dwIList = SHBrowseForFolder(bi)
        szPath = Space$(512)
        X = SHGetPathFromIDList(ByVal dwIList, ByVal szPath)
        
        If X Then
            wPos = InStr(szPath, Chr(0))
            BrowseFolder = Left$(szPath, wPos - 1)
        Else
            BrowseFolder = vbNullString
        End If
    End Function
    '*********** Code End *****************

    Then I opened the form "MannKendallPlot" in design view and added a button. I named the button "cmdPrintAll". I set the button caption to "Print All".
    In the form module, I added this code:
    Code:
    Private Sub cmdPrintAll_Click()
        Dim rs As dao.Recordset
        Dim sSQL As String
        Dim PDFPath As String
        Dim PDF_FileName As String
        Dim X As Integer  'counter
        Dim RC As Long
        Dim tmp As String
        Dim Printed_PDF As Boolean
        Dim Msg, Style, Title, Response
    
        Printed_PDF = False
    
        'get the save path
        PDFPath = BrowseFolder("What Folder you want to select?")
    
        'get the well name and COC data
        sSQL = "SELECT tblLinearRegressionResults.Well, tblLinearRegressionResults.COC"
        sSQL = sSQL & " FROM tblLinearRegressionResults"
        sSQL = sSQL & " ORDER BY tblLinearRegressionResults.Well, tblLinearRegressionResults.COC;"
        Set rs = CurrentDb.OpenRecordset(sSQL)
    
        If Not rs.BOF And Not rs.EOF Then
            rs.MoveLast
            'get record count
            RC = rs.RecordCount
            rs.MoveFirst
    
            X = 1
    
            'loop throough the recordset and generate the PDF file
            Do Until rs.EOF
                'set the global variables
                gLinearWellName = rs("Well")
                gLinearChemical = rs("COC")
    
                'generate the file name
                PDF_FileName = "\WellChemical" & X & ".PDF"
                'print the report
    
                tmp = PDFPath & PDF_FileName
    
                'you will need to modify this line - I don't have A2010 - don't know the proper command arguments
                DoCmd.OutputTo acOutputReport, "rptMannKendallbyWellCOC", acFormatpdf, PDFPath & PDF_FileName     '<<<<<<=============
    
                Printed_PDF = True
    
                X = X + 1
                rs.MoveNext
            Loop
    
            If Printed_PDF Then
                Msg = "Do you want merge the PDF files?"    ' Define message.
                Style = vbYesNo + vbCritical + vbDefaultButton2    ' Define buttons.
                Title = "Merge PDF Files"    ' Define title.
    
                ' Display message.
                Response = MsgBox(Msg, Style, Title)
                If Response = vbYes Then    ' User chose Yes.
                    '==========================================
                    ' here is where you would put the code to combine all of the
                    'PDF files into one PDF file
                    'sites I found to combine PDF files into one PDF using VBA
                    '
                    'http://www.khk.net/wordpress/2009/03/04/adobe-acrobat-and-vba-an-introduction/
                    'http://www.tek-tips.com/viewthread.cfm?qid=1648313
                    'http://www.anysitesupport.com/access-export-report-to-pdf-using-vba/
                    '==========================================
                Else
    
                End If
            End If
    
        End If
        rs.Close
        Set rs = Nothing
    
    End Sub
    The individual PDF file names are generated with an incrementing number so that in the future you can merge the PDFs into one file. It makes it easier if you have a file name with incrementing number.


    Note that there is not any error handler code.


    Hopefully this will get you started in solving your problem.

  8. #8
    bgreg00 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2013
    Posts
    4
    THANK YOU!! This is a great start. You've saved me so much time. I really appreciate it. I'm glad you were able to figure it out getting too involved with the data.

    I've got the code imbedded in my Maros 3.0 database and it seems to be working perfect except for two small issues: I would like to display the log scale plot in the report instead of the linear scale plot. Also for some reason, the fields to the right of the data plot are not populated (Mann Kendall S Statistic, Confidence in Trend, Coefficient of Variation, and Mann Kendall Concentration Trend). Any idea how to populate these fields?

    -Ben

  9. #9
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Wonderful. Glad to be of help.

    At this point, no, I don't have an idea to fix the other problems.
    Since I can't see the difference in the ver. 2.2 vs. ver 3, I can't offer any suggestions. When I can get to a computer with A2010, I'll try and install the ver 3 and take a look. But it might be a couple of weeks. I'll keep monitoring this thread.

    Good luck

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

Similar Threads

  1. Printing report
    By undee69 in forum Forms
    Replies: 1
    Last Post: 06-26-2012, 08:10 PM
  2. Report asking for parameters when printing
    By kris335 in forum Reports
    Replies: 3
    Last Post: 09-21-2011, 11:27 AM
  3. Report printing
    By Andrevw in forum Reports
    Replies: 1
    Last Post: 01-16-2011, 06:08 PM
  4. Printing Blank Report
    By andrewm in forum Reports
    Replies: 2
    Last Post: 11-24-2010, 05:30 PM
  5. Report Printing
    By newtoAccess in forum Reports
    Replies: 5
    Last Post: 12-02-2009, 07:46 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