none
Access 2016 report won't pick the location to save or assign a name to save the report under RRS feed

  • Question

  • Hi,

    I am not a database person and are struggling with this issue, hoping for some assistance please. 

    We are in the process of updating our Access 2003 to 2016.

    In 2003, when we click on a Report to Print, the way it is designed is it first saves to a location set for that report with a name automatically defined to the report without users input, once you hit save, a PDF copy is saved as well it Prints.

    In 2016 However, when we click on the same report, it does not populate that default location or define a name. It asks the user to set a location as well as assign a name before Save and Print. 

    I have attached images of both 2003 and 2016. Any suggestion would be great.

    Many Thanks in advance, any help will be greatly appreciated.

    Tuesday, November 20, 2018 7:47 PM

All replies

  • Hi,

    Something probably went wrong with your post because I don't see any attachments. Can you also post the code, if any? Thanks.

    Tuesday, November 20, 2018 7:47 PM
  • Hello,

    I am sorry but looks like i am unable to attach the images. What i do see is a lot of the Macros appear to have errors (they show exclamation mark) however, no error information is provided. Any suggestions? Code is VBA but i am not quite sure how i can share that. Many Thanks!

    Tuesday, November 20, 2018 9:03 PM
  • You might like to take a look at InvoicePDF.zip in my public databases folder at:

    https://onedrive.live.com/?cid=44CC60D7FEA42912&id=44CC60D7FEA42912!169

    Note that if you are using an earlier version of Access you might find that the colour of some form objects such as buttons shows incorrectly and you will need to  amend the form design accordingly.  

    If you have difficulty opening the link, copy the link (NB, not the link location) and paste it into your browser's address bar.

    In this little demo file the report (invoice) is saved in a sub-folder named as the customer name within a folder specified in the dialogue form which appears at first start-up.  If the sub-folder does not yet exist it is created.  The filename is a combination of the customer name and invoice number.  The code for this is:

    Private Sub cmdPDF_Click()

      On Error GoTo Err_Handler
        
        Const FOLDER_EXISTS = 75
        Const MESSAGE_TEXT1 = "No current invoice."
        Const MESSAGE_TEXT2 = "No folder set for storing PDF files."
        Dim strFullPath As String
        Dim varFolder As Variant
        
        If Not IsNull(Me.InvoiceNumber) Then
            ' build path to save PDF file
            varFolder = DLookup("Folderpath", "pdfFolder")
            If IsNull(varFolder) Then
                MsgBox MESSAGE_TEXT2, vbExclamation, "Invalid Operation"
            Else
                ' create folder if does not exist
                varFolder = varFolder & "\" & Me.Customer.Column(1)
                MkDir varFolder
                strFullPath = varFolder & "\" & Me.Customer.Column(1) & " " & Me.InvoiceNumber & ".pdf"
                ' ensure current record is saved before creating PDF file
                Me.Dirty = False
                DoCmd.OutputTo acOutputReport, "rptInvoice", acFormatPDF, strFullPath, True
            End If
        Else
            MsgBox MESSAGE_TEXT1, vbExclamation, "Invalid Operation"
        End If

    Exit_Here:
        Exit Sub
        
    Err_Handler:
        Select Case Err.Number
            Case FOLDER_EXISTS
            Resume Next
            Case Else
            MsgBox Err.Description
            Resume Exit_Here
        End Select

    End Sub


    Multiple invoices saved as a single PDF file, which can encompass more than one customer, are saved to the parent folder under a filename based on the current date/time, using the following code:

    Private Sub cmdCreateInvoices_Click()

        On Error GoTo Err_Handler
        
        Const FOLDER_EXISTS = 75
        Const MESSAGE_TEXT_1 = "No folder set for storing PDF files."
        Const MESSAGE_TEXT_2 = "No invoice(s) selected."
        Dim strFullPath As String
        Dim varFolder As Variant
        Dim varItem As Variant
        
        ' build path to save PDF file
        varFolder = DLookup("Folderpath", "pdfFolder")
        If IsNull(varFolder) Then
                MsgBox MESSAGE_TEXT_1, vbExclamation, "Invalid Operation"
        Else
            With Me.lstInvoices
                If .ItemsSelected.Count > 0 Then
                    'build list of invoice numbers in hidden control
                    Me.txtInvoiceList = ""
                    For Each varItem In .ItemsSelected
                        Me.txtInvoiceList = txtInvoiceList & "," & .ItemData(varItem)
                    Next varItem
                    'remove leading comma
                    Me.txtInvoiceList = Mid(Me.txtInvoiceList, 2)
                    strFullPath = varFolder & "\Invoices_" & Format(Now(), "yyyymmddhhnnss") & ".pdf"
                    DoCmd.OutputTo acOutputReport, "rptInvoiceMultiple", acFormatPDF, strFullPath, True
                Else
                    MsgBox MESSAGE_TEXT_2, vbExclamation, "Invalid Operation"
                End If
            End With
        End If

    Exit_Here:
        Exit Sub
        
    Err_Handler:
        Select Case Err.Number
            Case FOLDER_EXISTS
            Resume Next
            Case Else
            MsgBox Err.Description
            Resume Exit_Here
        End Select

    End Sub

    Multiple invoices saved as multiple files are each saved to the customer sub-folder using the following code:

    Private Sub cmdCreateInvoices_MultiFiles_Click()

        On Error GoTo Err_Handler
        
        Const FOLDER_EXISTS = 75
        Const MESSAGE_TEXT_1 = "No folder set for storing PDF files."
        Const MESSAGE_TEXT_2 = "No invoice(s) selected."
        Dim strFullPath As String
        Dim varFolder As Variant
        Dim varFolder_1 As Variant
        Dim varItem As Variant
        
        ' build path to save PDF file
        varFolder = DLookup("Folderpath", "pdfFolder")
        If IsNull(varFolder) Then
            MsgBox MESSAGE_TEXT_1, vbExclamation, "Invalid Operation"
        Else
            With Me.lstInvoices
                If .ItemsSelected.Count > 0 Then
                    For Each varItem In .ItemsSelected
                        Me.txtInvoiceList = .ItemData(varItem)
                        ' create folder if does not exist
                        varFolder_1 = varFolder & "\" & .Column(1, varItem)
                        MkDir varFolder_1
                        strFullPath = varFolder_1 & "\" & .Column(1, varItem) & " " & .ItemData(varItem) & ".pdf"
                        DoCmd.OutputTo acOutputReport, "rptInvoiceMultiple", acFormatPDF, strFullPath, True
                    Next varItem
                Else
                    MsgBox MESSAGE_TEXT_2, vbExclamation, "Invalid Operation"
                End If
            End With
        End If

    Exit_Here:
        Exit Sub
        
    Err_Handler:
        Select Case Err.Number
            Case FOLDER_EXISTS
            Resume Next
            Case Else
            MsgBox Err.Description
            Resume Exit_Here
        End Select

    End Sub

    Ken Sheridan, Stafford, England

    Tuesday, November 20, 2018 10:45 PM
  • What i do see is a lot of the Macros appear to have errors (they show exclamation mark) however, no error information is provided.

    If there's an exclamation point beside a macro action in design view, that just means that the action is one of many that are available but considered "unsafe" -- not that they aren't safe if you know what you're doing, but they can change data, delete objects, or even affect the file system, and therefore require extra care in their use.


    Dirk Goldgar, MS Access MVP
    Access tips: www.datagnostics.com/tips.html

    Tuesday, November 20, 2018 11:19 PM