output to - filename coding

J

Jake F

I created a button to save a report in a designated folder. The date
parameter is a box on the form the query for the report runs off of. I want
to include that date field in my report so I know what parameters I ran the
report on by looking at the contents of the folder. I tried to code the
start date into my stOuputFile portion but didn't do it correctly. Here's my
code so far for the button. Let me know if anything should be cleaned up as
well. Thanks.

Private Sub Cmd_MailEngineerRpt_Click()
On Error GoTo Err_Cmd_MailEngineerRpt_Click
Dim stDocName As String
stDocName = "rptjf_newengineer"
stOutputFile = "H:\Engineer Lists\New Engineer List " &
[frmjf_new]![EngineerStartDate] & ".pdf"
DoCmd.OutputTo acReport, stDocName, "PDF Format(*.pdf)", stOutputFile,
True, , , acExportQualityScreen
Me![TimeSent] = Now()
Exit_Cmd_MailEngineerRpt_Click:
Exit Sub
Err_Cmd_MailEngineerRpt_Click:
MsgBox Err.Description
Resume Exit_Cmd_MailEngineerRpt_Click
End Sub
 
J

Jeanette Cunningham

Jake,
there are format problems with dates in file names. For example use of / as
date separator won't work as part of a file name.
When I want to add a date to a file name I am exporting I usually use
Format(TheDateField, "dd-mm-yyyy")

Jeanette Cunningham
 
D

Douglas J. Steele

What exactly is in the EngineerStartDate control? Remember that file names
cannot include slashes, so you may need to use the Format function to remove
the slashes (or replace them with dashes)
 
J

Jake F

Oh right, I forgot that's a problem. I put the format(date,... part in, but
my date field is located on my form and this button is on a report so I'm
having trouble coding in the location of the date field. I tried

stDate = "Frmjf_new.EngineerStartDate"

but that doesn't work.


Jeanette Cunningham said:
Jake,
there are format problems with dates in file names. For example use of / as
date separator won't work as part of a file name.
When I want to add a date to a file name I am exporting I usually use
Format(TheDateField, "dd-mm-yyyy")

Jeanette Cunningham

Jake F said:
I created a button to save a report in a designated folder. The date
parameter is a box on the form the query for the report runs off of. I
want
to include that date field in my report so I know what parameters I ran
the
report on by looking at the contents of the folder. I tried to code the
start date into my stOuputFile portion but didn't do it correctly. Here's
my
code so far for the button. Let me know if anything should be cleaned up
as
well. Thanks.

Private Sub Cmd_MailEngineerRpt_Click()
On Error GoTo Err_Cmd_MailEngineerRpt_Click
Dim stDocName As String
stDocName = "rptjf_newengineer"
stOutputFile = "H:\Engineer Lists\New Engineer List " &
[frmjf_new]![EngineerStartDate] & ".pdf"
DoCmd.OutputTo acReport, stDocName, "PDF Format(*.pdf)", stOutputFile,
True, , , acExportQualityScreen
Me![TimeSent] = Now()
Exit_Cmd_MailEngineerRpt_Click:
Exit Sub
Err_Cmd_MailEngineerRpt_Click:
MsgBox Err.Description
Resume Exit_Cmd_MailEngineerRpt_Click
End Sub
 
J

Jake F

It's the date I use as a parameter for running my report off of.

Douglas J. Steele said:
What exactly is in the EngineerStartDate control? Remember that file names
cannot include slashes, so you may need to use the Format function to remove
the slashes (or replace them with dashes)

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Jake F said:
I created a button to save a report in a designated folder. The date
parameter is a box on the form the query for the report runs off of. I
want
to include that date field in my report so I know what parameters I ran
the
report on by looking at the contents of the folder. I tried to code the
start date into my stOuputFile portion but didn't do it correctly. Here's
my
code so far for the button. Let me know if anything should be cleaned up
as
well. Thanks.

Private Sub Cmd_MailEngineerRpt_Click()
On Error GoTo Err_Cmd_MailEngineerRpt_Click
Dim stDocName As String
stDocName = "rptjf_newengineer"
stOutputFile = "H:\Engineer Lists\New Engineer List " &
[frmjf_new]![EngineerStartDate] & ".pdf"
DoCmd.OutputTo acReport, stDocName, "PDF Format(*.pdf)", stOutputFile,
True, , , acExportQualityScreen
Me![TimeSent] = Now()
Exit_Cmd_MailEngineerRpt_Click:
Exit Sub
Err_Cmd_MailEngineerRpt_Click:
MsgBox Err.Description
Resume Exit_Cmd_MailEngineerRpt_Click
End Sub
 
J

Jake F

I got it figured out, I just had to change a couple symbols around and it
works. Thanks for your guys' help.

Jake F said:
Oh right, I forgot that's a problem. I put the format(date,... part in, but
my date field is located on my form and this button is on a report so I'm
having trouble coding in the location of the date field. I tried

stDate = "Frmjf_new.EngineerStartDate"

but that doesn't work.


Jeanette Cunningham said:
Jake,
there are format problems with dates in file names. For example use of / as
date separator won't work as part of a file name.
When I want to add a date to a file name I am exporting I usually use
Format(TheDateField, "dd-mm-yyyy")

Jeanette Cunningham

Jake F said:
I created a button to save a report in a designated folder. The date
parameter is a box on the form the query for the report runs off of. I
want
to include that date field in my report so I know what parameters I ran
the
report on by looking at the contents of the folder. I tried to code the
start date into my stOuputFile portion but didn't do it correctly. Here's
my
code so far for the button. Let me know if anything should be cleaned up
as
well. Thanks.

Private Sub Cmd_MailEngineerRpt_Click()
On Error GoTo Err_Cmd_MailEngineerRpt_Click
Dim stDocName As String
stDocName = "rptjf_newengineer"
stOutputFile = "H:\Engineer Lists\New Engineer List " &
[frmjf_new]![EngineerStartDate] & ".pdf"
DoCmd.OutputTo acReport, stDocName, "PDF Format(*.pdf)", stOutputFile,
True, , , acExportQualityScreen
Me![TimeSent] = Now()
Exit_Cmd_MailEngineerRpt_Click:
Exit Sub
Err_Cmd_MailEngineerRpt_Click:
MsgBox Err.Description
Resume Exit_Cmd_MailEngineerRpt_Click
End Sub
 
D

Douglas J. Steele

But what format? As I implied, if it's 01/11/2008, you can't use it in a
file name.

See whether

stOutputFile = "H:\Engineer Lists\New Engineer List " & _
Format(CDate([frmjf_new]![EngineerStartDate]), " yyyy\-mm\-dd") & ".pdf"

works any better. (The reason for using \- as the delimiter is to ensure
that Access doesn't chose the workstation's Date Separator character
instead)


--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Jake F said:
It's the date I use as a parameter for running my report off of.

Douglas J. Steele said:
What exactly is in the EngineerStartDate control? Remember that file
names
cannot include slashes, so you may need to use the Format function to
remove
the slashes (or replace them with dashes)

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Jake F said:
I created a button to save a report in a designated folder. The date
parameter is a box on the form the query for the report runs off of. I
want
to include that date field in my report so I know what parameters I ran
the
report on by looking at the contents of the folder. I tried to code
the
start date into my stOuputFile portion but didn't do it correctly.
Here's
my
code so far for the button. Let me know if anything should be cleaned
up
as
well. Thanks.

Private Sub Cmd_MailEngineerRpt_Click()
On Error GoTo Err_Cmd_MailEngineerRpt_Click
Dim stDocName As String
stDocName = "rptjf_newengineer"
stOutputFile = "H:\Engineer Lists\New Engineer List " &
[frmjf_new]![EngineerStartDate] & ".pdf"
DoCmd.OutputTo acReport, stDocName, "PDF Format(*.pdf)",
stOutputFile,
True, , , acExportQualityScreen
Me![TimeSent] = Now()
Exit_Cmd_MailEngineerRpt_Click:
Exit Sub
Err_Cmd_MailEngineerRpt_Click:
MsgBox Err.Description
Resume Exit_Cmd_MailEngineerRpt_Click
End Sub
 

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

Similar Threads


Top