0 Replies - 2208 Views - Last Post: 11 December 2009 - 09:37 AM

#1 P4L   User is offline

  • Your worst nightmare
  • member icon

Reputation: 34
  • View blog
  • Posts: 2,789
  • Joined: 07-February 08

Create a File with Date

Posted 11 December 2009 - 09:37 AM

Description: Copy and paste into new Module, follow the commented out instructions to ensure the correct location, and file type. This works for all file types. Once all code has been modified, run debug, and once debug is complete, check the location you set, and view the results. This will demonstrate how to create a file with the previous month/year combination as the file name. NOTE: This was built for use with MS Access
Function ExportFile()

    Dim stDocName As String

    Dim stMonth As Date

    Dim d As Variant
        
    stDocName = 'Enter Doc name here
    
    stMonth = Date 'Sets stMonth to be the same as the current date
    
    d = DateAdd("m", -1, Date) 'Subtracts one from the current month, and can be modified to add, or subtract, any number from the date, not just the month
      
    DoCmd.OutputTo acOutputQuery, stDocName, "Microsoft Excel 97-2003", "Enter file path here" & format(d, "mmmyy") & "File Type Here.xls" 'Remove "Enter File Path here and File type Here, and insert your file path and type in those locations.
      
End Function


Is This A Good Question/Topic? 0
  • +

Page 1 of 1