Outputto Macro

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • EORTIZ
    New Member
    • Sep 2007
    • 22

    Outputto Macro

    I want to be able to export a query, in which a folder s created and the file is named based on two fileds of the query. I found the MAcro Outputto, but in order to use it you need to say exactly the path and name of the file.

    I need for example: export query which has as parameters the variable names AMP_ID and Start Date with values 10111 and 1/1/2008, respectivley to be saved in C:\Myfiles\2008-01\10111\AMP_20 0801_10111.xls

    If I have another query with parameters AMP_ID=10201 and Start Date=1/1/2008 to be saved in C:\Myfiles\2008-01\10201\AMP_20 0801_10201.xls
  • puppydogbuddy
    Recognized Expert Top Contributor
    • May 2007
    • 1923

    #2
    Try this. Keep in mind that the start date has to be formatted as a string without slashes or hyphens in order to be legal within a file name.


    DoCmd.OutputTo acOutputReport, "YourAccessRepo rtName", acFormatXLS,
    "C:\Myfiles \" & AMP_ID & "\" & Format([Start Date], "mmddyyyy") & ".xls", False

    Comment

    Working...