Create Part of File Name from field in Data

StephenB

Registered User.
Local time
Today, 01:42
Joined
Apr 18, 2002
Messages
101
Hello. I have the below from a consultant a few years ago. It exports a report and names the report to include today's name. So today's file would be "TODAY'SFILE 07-14-2009.snp"
-------------
Function Export()
Dim strdate As String
Dim stAppName As String

strdate = Format$(Date, "mm-dd-yyyy")
DoCmd.SetWarnings False
DoCmd.Hourglass True
DoCmd.OutputTo acReport, "Report Name", "snp", "\\server\Folder\File Name " & strdate & ".snp", False, "", 0

stAppName = """C:\WINDOWS\explorer.exe"" , \\server\Folder"
Call Shell(stAppName, 1)

DoCmd.Hourglass False
DoCmd.SetWarnings True
DoCmd.Quit


End Function

-------------
What I'd like to do instead, is use the date from a field in the data called "WORKDATE".

The reason for this is that the report may reflect work from other days, not just today. So I'd like the work date in the file name, instead of today. The date value in "WORKDATE" will always be the same in all records of the output.

Thanks in advance for any help or for pointing me to the right thread.
 
Try something like:

Code:
strdate = DLookup("[WORKDATE]", "[query_for_the_report]")

This assumes that he report is based on a saved query. You will need to substitute the [query_for_the_report] with the actually name of the query.
 

Users who are viewing this thread

Back
Top Bottom