J
johnnywinter via AccessMonster.com
I have working code (thanks to this board) that Outputs report as Snapshot
files with unique names sourced from fields in a recordset.
But these are now saved into a predefined directory C:\Commissions\ .
Anyone have code or link to where I can find out how to:
make a subdirectory (if it does not exist already) and name the subdirectory
using values of [MONTHNAME] [YEAR] that are in each record in the recordset.
So i will end up with:
C:\Commissions\ [YEAR] [MONTHNAME] \ name of SNP file
Here is my code to output & name the snapshot file based on teh record in the
recordset.
********************************************************************************************************
Private Sub Command3_Click()
Dim rsRep As DAO.Recordset
Dim strReport As String
strReport = "Curr Mo Collections EACH Rep"
Set rsRep = DBEngine(0)(0).OpenRecordset("REPMASTER1", dbOpenTable,
dbForwardOnly)
Do Until rsRep.EOF
doCmd.OpenReport strReport, acViewPreview, , "[Rep]= '" & rsRep.Fields!REP
& "' "
doCmd.OutputTo ObjectType:=acOutputReport, _
objectname:=strReport, _
outputformat:=acFormatSNP, _
outputfile:="C:\Commissions\" & rsRep.Fields!MONTHNAME & " " & rsRep.
Fields!YEAR & " " & rsRep.Fields!REP & " " & rsRep.Fields!repNAME & ".snp"
doCmd.Close acReport, strReport, acSaveNo
rsRep.MoveNext
Loop
rsRep.Close
Set rsRep = Nothing
End Sub
files with unique names sourced from fields in a recordset.
But these are now saved into a predefined directory C:\Commissions\ .
Anyone have code or link to where I can find out how to:
make a subdirectory (if it does not exist already) and name the subdirectory
using values of [MONTHNAME] [YEAR] that are in each record in the recordset.
So i will end up with:
C:\Commissions\ [YEAR] [MONTHNAME] \ name of SNP file
Here is my code to output & name the snapshot file based on teh record in the
recordset.
********************************************************************************************************
Private Sub Command3_Click()
Dim rsRep As DAO.Recordset
Dim strReport As String
strReport = "Curr Mo Collections EACH Rep"
Set rsRep = DBEngine(0)(0).OpenRecordset("REPMASTER1", dbOpenTable,
dbForwardOnly)
Do Until rsRep.EOF
doCmd.OpenReport strReport, acViewPreview, , "[Rep]= '" & rsRep.Fields!REP
& "' "
doCmd.OutputTo ObjectType:=acOutputReport, _
objectname:=strReport, _
outputformat:=acFormatSNP, _
outputfile:="C:\Commissions\" & rsRep.Fields!MONTHNAME & " " & rsRep.
Fields!YEAR & " " & rsRep.Fields!REP & " " & rsRep.Fields!repNAME & ".snp"
doCmd.Close acReport, strReport, acSaveNo
rsRep.MoveNext
Loop
rsRep.Close
Set rsRep = Nothing
End Sub