Report with Date and Time

Steve5

Registered User.
Local time
Today, 14:47
Joined
Apr 23, 2003
Messages
42
Hello All,

I have question about placing the date and time into the title of the report.

For example:

I send a report to a folder from my DB and looks like this.

money.snp


I want it to look like this

money 12-09-03 5:29pm.snp

Is this possible????

I hope all you DB Pro's can help me :)

Below is the code I tried but it provided an error.

Private Sub Command508_Click()
On Error GoTo Err_Command508_Click

Dim DateTime As Date
DateTime = Now()

DoCmd.OpenReport "money", acViewPreview, "", "", acHidden
DoCmd.OutputTo acOutputReport, "money", acFormatSNP, "K:\itd\webdocs\inbasket\business_process_dynamic\money_" & Now & ".snp"
DoCmd.Close acReport, "money_" & Now
DoCmd.Close acReport, "money"

Exit_Command508_Click:
Exit Sub

Err_Command508_Click:
MsgBox Err.Description
Resume Exit_Command508_Click

End Sub
 
Steve5,

Try using the Date and Time function instead of Now(). I got it working using the following code. See changes in red.

HTH Skip



Private Sub Command508_Click()
On Error GoTo Err_Command508_Click

Dim DateTime As Date
DateTime = Now()

DoCmd.OpenReport "money", acViewPreview, "", "", acHidden
DoCmd.OutputTo acOutputReport, "money", acFormatSNP, " K:\itd\webdocs\inbasket\business_process_dynamic\money_" & Now & ".snp"
DoCmd.Close acReport, "money_" & Date & Time
DoCmd.Close acReport, "money"

Exit_Command508_Click:
Exit Sub

Err_Command508_Click:
MsgBox Err.Description
Resume Exit_Command508_Click

End Sub
 
Skip thank-you so much for responding - However>

I tried your suggestion and I get an error message [Object Required]

Here is the full code - with your changes.

Private Sub Command600_Click()
On Error GoTo Err_Command600_Click

Dim DateTime As Date
DateTime = Now()

DoCmd.OpenReport "R_Idle MR", acViewPreview, "", "", acHidden
DoCmd.OutputTo acOutputReport, "R_Idle MR", acFormatSNP, "K:\itd\webdocs\inbasket\business_process_dynamic\mfg_ops\material_control_logistics\Idle Material Report\R_Idle MR" & Now().snp
DoCmd.Close acReport, "R_Idle MR" & Date & Time
DoCmd.Close acReport, "R_Idle MR"

Exit_Command600_Click:
Exit Sub

Err_Command600_Click:
MsgBox Err.Description
Resume Exit_Command600_Click

End Sub
 

Users who are viewing this thread

Back
Top Bottom