Hello Vickie.

If there is only one record in the table you could do something like this.

TheFileName = DLookup("FieldWithPath","TableName") & "\" & "QueryName\" & 
TheDate & ".xls"




________________________________
From: Vickie <[email protected]>
To: [email protected]
Sent: Sat, April 24, 2010 2:53:27 PM
Subject: [ms_access] Export query to Excel using variable file name plus query 
name plus current date

  
The code was originally hard coded to export a query to a specific path as 
follows:
TheFileName = "S:\Comparision Reports Access Queries\qryExportTo 
ExcelBudgetInfo- " & TheDate & ".xls"

DoCmd.TransferSprea dsheet acExport, 8, "qryExportToExcelBu dgetInfo" , 
TheFileName, True, ""

MsgBox ("File Exported to " & TheFileName)

The above query exports to:
S:\Comparision Reports Access Queries\qryExportTo ExcelBudgetInfo- 04_24_10. xls

I need to export a query to a path stored in a table plus add the remainder of 
the file name with the current date to Excel.

For example, the lookup table has a field C:\Reports\. That path can be changed 
at any time. When a query is exported, it needs to use the path in the lookup 
table plus the query name plus the date.

Example: This query exports to:
C:\Reports\qryExpor tToExcelBudgetIn fo-04_24_ 10.xls

I am having trouble combining the path variable name with the query name plus 
the current date to create TheFileName.

Vickie





      

[Non-text portions of this message have been removed]

Reply via email to