Results 1 to 2 of 2
  1. #1
    Enrightt is offline Novice
    Windows 8 Access 2007
    Join Date
    Oct 2015
    Posts
    10

    Form Me. Values aren't getting captured in Loop

    Hello All,

    I'm trying to mass output PDFs from an Access form. The form ties to a report which is driven of the current Form values. The following code is intended to cycle through all available form records and generate a corresponding report to pdf.

    Without the loop it works, but when it cycles through the records, it seems that it's going to fast for Access. Even though the Access starts going to subsequent form records, the 'Me. Values' never update to the current record and the script just rewrites over the same file over and over again.



    Any idea on how to slow this down to have the Me. Values update for each record appropriately?

    Code:
    FileName = Me.Supplier_Name & " - " & Me.Invoice_Num
    Filepath = Environ("UserProfile") & "\Desktop\" & FileName & ".pdf"
    
    
    While Me.CurrentRecord < Me.Recordset.RecordCount
        'CurrentDb.Execute "Invoice Header - Report"
        DoCmd.OutputTo acOutputReport, "Invoice PDF - Report", acFormatPDF, Filepath
        DoCmd.GoToRecord , , acNext
    Wend
    
    
    End Sub

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    The Me values are retrieved prior to the loop. Try within the loop.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Macro Loop values in Form ang get values to query
    By mauryc1990 in forum Programming
    Replies: 13
    Last Post: 12-22-2017, 08:30 AM
  2. Replies: 5
    Last Post: 12-01-2017, 01:40 PM
  3. Replies: 15
    Last Post: 01-17-2014, 12:08 PM
  4. Replies: 8
    Last Post: 12-18-2013, 03:00 PM
  5. Replies: 3
    Last Post: 03-10-2013, 07:04 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