export with formatting: current/previous month code for filename

Nyolls

New member
Local time
Today, 12:24
Joined
Feb 11, 2014
Messages
1
Hi there,

I currently use the following code in the "output file" field of my exportWithFormatting action in my access 2010 macro to export query results to excel file with the current date added to the end:

"C:\\Directory\FILENAME-" & Format(Date(),"mm-dd-yyyy") & ".xlsx"

For a new report I'm creating, the data is from the previous month.
In the criteria for the actual query, I have the following code so it will only pull data from the previous month:

">=DateSerial(Year(Now()),Month(Now())-1,1) And <DateSerial(Year(Now
()),Month(Now()),0+1)"

I was hoping to use something similar to this for the output file name, but I can't seem to figure out the syntax. It basically just needs to say "FILENAME & then put current month -1 and year, ie: "FILENAME-January 2013.xls" or something to that effect. Can anyone give me a hand with this?
 

Users who are viewing this thread

Back
Top Bottom