Appending Date to File Name Syntax Question

J

Jim Ory

Using WinXP and Access2K2

In the following 'on click' event in visual basic a text file is produced
and sent to a file folder. The file name is always the same. I'd like to be
able to append the current date to the file name ending up with as an
example; "ADIF_11032007.adi", or whatever date it happens to be at the time
of the report. My code so far:

Dim stDocName As String
Dim MyDate As String

MyDate = Date


'Selects which report to use based on queries for each report
If optQSL = 1 Then
stDocName = "rptADIF_eQSL"
ElseIf optQSL = 2 Then
stDocName = "rptADIF_LoTW"
End If

DoCmd.OutputTo acOutputReport, stDocName,_ acFormatTXT,
"C:\Ham\ADIF_Files\ADIF.adi"

Exit_Adif_Click:
Exit Sub

Err_Adif_Click:
MsgBox Err.Description
Resume Exit_Adif_Click

End Sub
------------------------------------------------------------------------------------------------

In visual basic help:

Date Function Example
This example uses the Date function to return the current system date.

Dim MyDate
MyDate = Date ' MyDate contains the current system date.
 
T

Tom van Stiphout

On Sat, 3 Nov 2007 10:44:01 -0700, Jim Ory
<jim[at]oryfamilyhistory[dot][comma]> wrote:

Sure:
DoCmd.OutputTo acOutputReport, stDocName,_ acFormatTXT,
"C:\Ham\ADIF_Files\ADIF" & Format$(Date,"mmddyyyy") & ".adi"

-Tom.
 
J

Jim Ory

Tom,
Thank you. Works just the way I thought I'd like. This takes so much work
out of the process I had been using.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top