How to make Subdirectory using OutputTo for Snapshot files from recordset

  • Thread starter johnnywinter via AccessMonster.com
  • Start date
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
 
P

pietlinden

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.

build a string with [monthname] [year] and then use this:
http://www.vbnet.mvps.org/code/file/nested.htm
 
J

johnnywinter via AccessMonster.com

Pietlinden,
Thanks for another great tip.



I have working code (thanks to this board) that Outputs report as Snapshot
files with unique names sourced from fields in a recordset.
[quoted text clipped - 5 lines]
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.

build a string with [monthname] [year] and then use this:
http://www.vbnet.mvps.org/code/file/nested.htm
 

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