Results 1 to 4 of 4
  1. #1
    DavidCB is offline Novice
    Windows 10 Access 2016
    Join Date
    Jan 2022
    Posts
    4

    Save report to file for each in list


    Greetings,

    Needed to be pointed in the right direction.

    I have two tables, StoreListTBL (StoreID [Primary], SiteName, Address, State) and EmpListTBL (EmpNumb [Primary], StoreID, Fname, Lname, ).

    Trying to automated a process that saves a PDF report to file for each Store listing the assigned employees.

    The Reports are generated monthly and saved as StoreID+Date (EmpListTX001-01172022) and Saved to a Folder based on State (Z:\Texas\EmpListTX001-01172022)

    I know there are a few ways to skin a cat, I have a form that shows the required data based on a query [StoreID], what is the best way to get this to a report format?

    Do I even need to do this from the Form?

    A million Thank you's in advance,

    DavidCB

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,524
    something like:

    the form (fMyForm) has a listbox (lstClients) of all clients
    the code will cycle thru a listbox , get next name, , creating the pdf file

    the query (in the report) uses the listbox to pull only that person selected in the list.
    i.e.: select * from table where [ClientID]=forms!fMyForm!lstClients


    the folder, vLoc , is also in the listbox in another column. col 3, but in vb code columns start with zero
    Code:
    sub btnGo_click()
    Dim i As Integer
    dim vItm, vSendTo
    Code:
    
    vDir = "c:\temp\"
    
    For i = 0 To lstClients.ListCount - 1
       vItm= lstClients.ItemData(i)  'get next item in list data
       lstClients =vItm      'set listbox to that item
    
       vSendTo = lstClients.column(1)  'get clients email addr. (note in VB, columns begin with zero)
    
    vLoc = lstClients.column(2) 'col 3 has folder name, but in vb code, columns begin with zero, so col3 = lstClients.column(2)
    vFilename = "rInvoice_" & vLoc & ".pdf" vFile = vDir & vFileName 'create invoice data file docmd.OutputTo acOutputReport ,"rInvoice",acFormatPDF,vFile 'or docmd.OutputTo acOutputQuery ,"qsMyQuery",acFormatPDF,vFile 'email invoice directly DoCmd.SendObject acSendReport, "rInvoice", acFormatPDF, vSendTo, , , "Subject", "message" Next end sub

  3. #3
    DavidCB is offline Novice
    Windows 10 Access 2016
    Join Date
    Jan 2022
    Posts
    4
    OK, think I got it, will run through this,

    Thanks

    DavidCB

  4. #4
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,914
    Main report for store.
    Subreport for employees.
    Use your query as a recordset for each store and output report to pdf.
    Attach pdf file to email.
    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

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

Similar Threads

  1. Report to save as Excel file
    By ashu.doc in forum Reports
    Replies: 7
    Last Post: 07-20-2015, 10:18 AM
  2. save report as pdf file
    By linoreale in forum Reports
    Replies: 5
    Last Post: 01-31-2015, 10:47 AM
  3. Save a Report to a PDF file. Access 2007
    By casinc815 in forum Reports
    Replies: 4
    Last Post: 06-20-2014, 10:38 AM
  4. Export report as RTF but save file name as .doc
    By Ruegen in forum Programming
    Replies: 3
    Last Post: 06-06-2014, 03:16 AM
  5. Save a report file without preview
    By alex__ice in forum Reports
    Replies: 2
    Last Post: 04-16-2013, 08:13 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