Results 1 to 6 of 6
  1. #1
    mar7632 is offline Advanced Beginner
    Windows 8 Access 2016
    Join Date
    Feb 2019
    Location
    Spain - Madrid
    Posts
    72

    Exporting a PDF file by saving it from a form.

    Hi again,

    I have a problem related to exporting a PDF file, which has the report structure, from a form by using a command button. What I want is to save the certain record I am (determine by the id_item), in my computer using a PDF format.

    The code I am Using:



    Code:
    Private SubcboGuardarArchivoPDF_Click()
    
    DoCmd.OutputTo acReport, "Informe_Correo", "(*.pdf)", "C:\" & codigoRFQ & ".pdf", False, ""
    
    End Sub
    It keeps saving all the record I have. Could you help me with this issue, please?

    Thank you in advance,

    Regards.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    First open report filtered to the one record then run OutputTo.
    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.

  3. #3
    Minty is offline VIP
    Windows 10 Access 2016
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,157
    I'm sure you have asked this before...

    You need to open the report to the specific record then while it is open, do the output to. Air code (untested) something like

    Code:
    Dim strWhere as String
    
    strWhere = "[codigoRFQ] = " & codigoRFQ 
    
    DoCmd.OpenReport "Informe_Correo", acViewPreview, , strWhere
    DoCmd.OutputTo acReport, "Informe_Correo", "(*.pdf)", "C:\" & codigoRFQ & ".pdf", False, ""
    DoCmd.Close acReport, "Informe_Correo"
    This assumes codigoRFQ is a number. If it's text then add ' ' around the where string.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  4. #4
    mar7632 is offline Advanced Beginner
    Windows 8 Access 2016
    Join Date
    Feb 2019
    Location
    Spain - Madrid
    Posts
    72
    Thank you for your reply, I have asked a similar question but related to a printing button.

    codigoRFQ is a text field. I don really understand what are you saying with: If it's text then add ' ' around the where string.


  5. #5
    Minty is offline VIP
    Windows 10 Access 2016
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,157
    You always need to use the correct format for the data type. This means using delimiters.

    So for your criteria as a string you would use ' as the delimiter;

    Code:
    strWhere = "[codigoRFQ] = '" & Me.codigoRFQ  & "'"
    For a Date field you would use # as the delimiter, and for safety format it to a universally recognised standard;
    Code:
    strWhere = "[YourDateField] = #" & Format( Me.YourDateFieldControl ,"yyyy-mm-dd" & "#"
    And finally for a number data type
    Code:
    strWhere = "[YourNumberField] = " & Me.YourNumberControl 
    Remember this as it always applies!
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  6. #6
    mar7632 is offline Advanced Beginner
    Windows 8 Access 2016
    Join Date
    Feb 2019
    Location
    Spain - Madrid
    Posts
    72
    Thank you so much Minty and June7! I've finally solved this problem with your help!

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

Similar Threads

  1. Replies: 2
    Last Post: 04-01-2016, 10:38 AM
  2. Exporting Form to PDF - Output File Name
    By thexxvi in forum Access
    Replies: 13
    Last Post: 05-26-2015, 07:25 PM
  3. saving file as a PDF
    By mike02 in forum Reports
    Replies: 1
    Last Post: 08-14-2013, 03:15 PM
  4. Replies: 21
    Last Post: 01-24-2012, 06:21 PM
  5. Exporting and saving file as [FORM]![FORM1]![FILENAME]
    By Elbows in forum Import/Export Data
    Replies: 1
    Last Post: 10-18-2011, 10:02 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