J
jkendrick75
I would like to be able to save a snapshot report (created through code) to
automatically be saved to a subfolder based on the reports' date. the dates
are in a mm/dd/yyyy format, but i would like the folder to be the written
form of the month. example: 8/4/2005 would be saved to
"\\blah\blah\August_2005\name of report.snp". i can create and save the
report to a folder just fine, i just need the code to convert the date and
make it a folder name. the code i currently have is below:
Private Sub cmdOpen_Click()
On Error GoTo Err_cmdOpen_Click
Dim stDocName As String, SNPmyReport As String, myReport As String
stDocName = "rptDailyProductionNew"
'Debug.Print chkSend
If Me.chkSend = False Then
'Open report for viewing
DoCmd.OpenReport stDocName, acViewPreview
Else
'Code creates and saves a snapshot file of the report being opened to a
network folder.
Dim myfile As String
myReport = "Daily_Production_Report_" & Replace(CDate(Me!txtDate), "/", "")
& "_P" & _
Me!txtPlant.Value & "_S" & Me!txtShift.Value
'SNPmyReport is both a location and file name for the snapshot.
SNPmyReport = "\\servername\sharename\Daily Production Reports\" & myReport
& ".snp"
DoCmd.OpenReport stDocName, acViewPreview
'Creates a snapshot file and saves it to a specific network folder
DoCmd.OutputTo acReport, stDocName, "SnapshotFormat(*.snp)", SNPmyReport,
True, ""
DoCmd.Close acReport, stDocName
End If
Exit_cmdOpen_Click:
Exit Sub
Err_cmdOpen_Click:
If Err.Number = 2501 Then
Resume Next
Else
MsgBox Err.Description
Resume Exit_cmdOpen_Click
End If
End Sub
automatically be saved to a subfolder based on the reports' date. the dates
are in a mm/dd/yyyy format, but i would like the folder to be the written
form of the month. example: 8/4/2005 would be saved to
"\\blah\blah\August_2005\name of report.snp". i can create and save the
report to a folder just fine, i just need the code to convert the date and
make it a folder name. the code i currently have is below:
Private Sub cmdOpen_Click()
On Error GoTo Err_cmdOpen_Click
Dim stDocName As String, SNPmyReport As String, myReport As String
stDocName = "rptDailyProductionNew"
'Debug.Print chkSend
If Me.chkSend = False Then
'Open report for viewing
DoCmd.OpenReport stDocName, acViewPreview
Else
'Code creates and saves a snapshot file of the report being opened to a
network folder.
Dim myfile As String
myReport = "Daily_Production_Report_" & Replace(CDate(Me!txtDate), "/", "")
& "_P" & _
Me!txtPlant.Value & "_S" & Me!txtShift.Value
'SNPmyReport is both a location and file name for the snapshot.
SNPmyReport = "\\servername\sharename\Daily Production Reports\" & myReport
& ".snp"
DoCmd.OpenReport stDocName, acViewPreview
'Creates a snapshot file and saves it to a specific network folder
DoCmd.OutputTo acReport, stDocName, "SnapshotFormat(*.snp)", SNPmyReport,
True, ""
DoCmd.Close acReport, stDocName
End If
Exit_cmdOpen_Click:
Exit Sub
Err_cmdOpen_Click:
If Err.Number = 2501 Then
Resume Next
Else
MsgBox Err.Description
Resume Exit_cmdOpen_Click
End If
End Sub