Help with automating file name

  • Thread starter Thread starter mattc66 via AccessMonster.com
  • Start date Start date
M

mattc66 via AccessMonster.com

I have the following code that exports the below query to excell. I would
like the files name to include the month and date. How would I format this?

DoCmd.OutputTo acOutputQuery, "qryShopOrderSqFtShippedSummaryExport",_
acFormatXLS, "W:\Cokato\Production\ProdRoomRpt.xls"
 
Hi, Matt.
I would
like the files name to include the month and date.

Uh, . . . the date _always_ includes the month, unless you're referring to a
different calendar than the rest of us normally use. Perhaps you mean the
month and day? If so, try:

DoCmd.OutputTo acOutputQuery, "qryShopOrderSqFtShippedSummaryExport",_
acFormatXLS, "W:\Cokato\Production\ProdRoomRpt_" & _
Month(Date()) & "_" & Day(Date()) & ".xls"

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips and tutorials.
Blogs: www.DataDevilDog.BlogSpot.com, www.DatabaseTips.BlogSpot.com
http://www.Access.QBuilt.com/html/expert_contributors2.html for contact
info.
 
mattc66 said:
I have the following code that exports the below query to excell. I would
like the files name to include the month and date. How would I format this?

DoCmd.OutputTo acOutputQuery, "qryShopOrderSqFtShippedSummaryExport",_
acFormatXLS, "W:\Cokato\Production\ProdRoomRpt.xls"

Hi Matt,

try this:

DoCmd.OutputTo acOutputQuery, "qryShopOrderSqFtShippedSummaryExport",_
acFormatXLS, "W:\Cokato\Production\ProdRoomRpt "&format(now(),"mmm dd")&".
xls"

You may want to play with the date formatting to display the desired date
format that you want.

Hope this help.
 
Back
Top