Results 1 to 11 of 11
  1. #1
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    2,095

    "Access seems to forget what acFormatPDF" means?"

    In the code below, the first "DoCmd.OutputTo acOutputReport" directs the use of acFormatPDF for the output format. The second "DoCmd.OutputTo acOutputReport" prompts for the format. Thjs started happening after many tens of executions of the code. Any ideas how to fix this issue?

    Code:
    Option Compare Database
    Option Explicit
    Dim I As Integer
    Public Function PrintDailyMenu(ChoiceNum As Integer)
    '*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
    '  ChoiceNum 2 > 8 means Sunday > Saturday
    '*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
    Dim strPDFname As String      'As assigned for each day requested
    Dim strPDFPrintQ As String  'As merged by function MergePDFs
    Dim strrptName As String      'Varies depending on single or all seven
    Dim intChoice As Integer
    Dim lngNxtDay As Long         'LoadMenuStrings returns date values for Saturdays
    Dim strSearch As String
    Dim strTempName As String
    Dim dummy As Variant
    Dim lngDay As Long
    Dim intBegin As Integer       'Start loop here
    Dim intEnd As Integer         'End loop here
    
    
    
    
    strPDFname = strPDFMenusFldr & DLookup("Day", "tblWeekDays", "Id = 9") & "Menu" & ".PDF"
    strrptName = "rptDailyMenu"
    
    
    strPDFPrintQ = strPDFMenusFldr & "Print-Q\"
    
    
    On Error GoTo Err_Handler
        
    
    
    'Set the looping values for the selected day(s)
    If ChoiceNum = 9 Then
        intBegin = 2
        intEnd = 8
    Else
        intBegin = ChoiceNum
        intEnd = ChoiceNum
    End If
    
    
    For intChoice = intBegin To intEnd
    
    
        lngNxtDay = LoadMenuStrings(intChoice)
        intBBDay = intChoice - 1
        
        'First, collect the seven days, Sunday through Saturday
        strPDFname = strPDFPrintQ & intChoice - 1 & DLookup("Day", "tblWeekDays", "Id = " & intChoice) & "Menu" & ".PDF"
        DoCmd.OutputTo acOutputReport, "rptDailyMenu", acFormatPDF, strPDFname, False
    
    
        'Save the same day, but as a single image/page (Adding the day number at the head of the PDF name)
        lngDay = DLookup("F" & intChoice, "tblMenuSheet", "menuID = 1")
        strTempName = strFilesFldr & lngDay & "-" & DLookup("Day", "tblWeekDays", "Id = " & intChoice) & "Menu" & ".PDF"
        DoCmd.OutputTo acOutputReport, "rptMenuStyle1, acFormatPDF, strTempName, False"
        
    Next intChoice
    
    
    'Okay, we got what was requested.  Now OPEN the print Q where the file(s) can be either opened for inspection or sent to the printer.
    Call OpenPDFPrintQ
    
    
    Exit_Handler:
       Exit Function
       
    Err_Handler:
        If Err.Number = 2501 Then     'Ignore the 2501 errors
            Resume Next
       Else
            MsgBox "Error " & Err.Number & " in sub ""PrintDailyMenu"" attempting to populate menu lines " & Err.Description
            Resume Exit_Handler
       End If
    
    
    End Function
    
    (snip)


  2. #2
    madpiet is offline Expert
    Windows 10 Office 365
    Join Date
    Feb 2023
    Posts
    564
    I would check for missing libraries. For some reason, a core library seems to be unregistered or something.

    What happens if you try to compile your VBA code in the database? I'd expect that you will get an error. if you compile and get an error, go into the References and you may find some libraries marked MISSING.

  3. #3
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    2,095
    The references have not been changed. Referring to the OP, the first OutputTo executes successfully. The second OutputTo pops-up the prompt you see below. That same sequence runs 7 times and behaves exactly the same.
    Click image for larger version. 

Name:	001.jpg 
Views:	24 
Size:	39.0 KB 
ID:	53033

  4. #4
    Gustav's Avatar
    Gustav is offline Advanced Beginner
    Windows 11 Office 365
    Join Date
    Jan 2025
    Posts
    32
    Correct all your code to correct syntax:
    Code:
        DoCmd.OutputTo acOutputReport, "rptDailyMenu", acFormatPDF, strPDFname, False
        DoCmd.OutputTo acOutputReport, "rptMenuStyle1, acFormatPDF, strTempName, False"

  5. #5
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,550
    Quote Originally Posted by Gustav View Post
    Correct all your code to correct syntax:
    Code:
        DoCmd.OutputTo acOutputReport, "rptDailyMenu", acFormatPDF, strPDFname, False
        DoCmd.OutputTo acOutputReport, "rptMenuStyle1, acFormatPDF, strTempName, False"
    Nice catch.

    I was misled by the
    Thjs started happening after many tens of executions of the code.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  6. #6
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 11 Office 365
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,879
    Quote Originally Posted by Gustav View Post
    Correct all your code to correct syntax:
    Code:
        DoCmd.OutputTo acOutputReport, "rptDailyMenu", acFormatPDF, strPDFname, False
        DoCmd.OutputTo acOutputReport, "rptMenuStyle1, acFormatPDF, strTempName, False"
    Is there a misplaced " in the second line?
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

  7. #7
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,550
    Quote Originally Posted by moke123 View Post
    Is there a misplaced " in the second line?
    Yes. The second parameter for the OutputTo has too many entries.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  8. #8
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2013 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,250
    In the early days of when MS introduced the PDF option to Access I was having a similar issue and my way out was to use the actual value of the acFormatPDF which is "PDF Format (*.pdf)", worked great for me.
    Code:
    'DoCmd.OutputTo acOutputReport, "rptDailyMenu", acFormatPDF, strPDFname, False
    DoCmd.OutputTo acOutputReport, "rptDailyMenu", "PDF Format (*.pdf)", strPDFname, False
    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  9. #9
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    2,095
    Not to place blame, but that error was most certainly the results of a recent cut/paste operation to that statement. I might be getting older, but I sure didn't type the statement that way. GOOD GRIEF!
    Thanks,
    Bill

    (PS) Notice it was a novice that caught the error.

  10. #10
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,550
    Quote Originally Posted by GraeagleBill View Post
    (PS) Notice it was a novice that caught the error.
    Ahem, only here, and that just goes on the number of posts.
    Hardly a novice and @Gustav has way more posts over on UA.
    More than yours and they will likely all be replies, not questions.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  11. #11
    isladogs's Avatar
    isladogs is offline Access MVP / VIP
    Windows 10 Office 365
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    6,204
    As I've mentioned before, Gustav is an Access MVP - definitely not a novice
    Colin Riddington, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I know I don't know, I keep quiet!

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

Similar Threads

  1. Replies: 1
    Last Post: 02-28-2017, 12:29 PM
  2. Access to PDF Mixed Characters acFormatPDF
    By ekryez in forum Access
    Replies: 10
    Last Post: 03-06-2015, 03:42 PM
  3. Replies: 4
    Last Post: 03-05-2015, 06:07 PM
  4. Replies: 4
    Last Post: 05-10-2014, 12:50 PM
  5. Forget Password Form
    By jj1 in forum Access
    Replies: 1
    Last Post: 05-09-2014, 09:52 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