Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

OutPutTo 1

Status
Not open for further replies.

shart00

Technical User
Jun 16, 2003
63
US
What I am trying to do is output a report as a snaphot to a folder on the server. The problem is that since these reports change daily, I would like to put the date ran in the file name somewhere. I.E. Attendance 021805.snp (The format of the date does not matter, only that it is there)
As a starting point someone showed me the following.
mDofReport = Format(Date, "yyyy-mm")
DoCmd.OutputTo , "Attendance Absence Summary By Plant", acFormatSNP, "I:\Attendance Reports\Attendance Absence Summary By Plant" & mDofReport & ".snp", True


I know it does not have the date correctly but it would be a starting point. However, the error:
Compile Error
Argument not optional

Keeps appearing. Any suggestions?
 
This should work:

DoCmd.OutputTo acOutputReport, "Attendance Absence Summary By Plant", acFormatSNP, "I:\Attendance Reports\Attendance Absence Summary By Plant" & mDofReport & ".snp", True
 
I am tring to do the same thing only I am attempting to make a folder by day since there are several reports to print.

I tried:
mDofReport = Format([Begining Date], "mm-dd-yyyy")
DoCmd.OutputTo acOutputReport, "SW Regional", acFormatSNP, "g:\" & mDofReport & "\SW Key Figures " & mDofReport & ".snp"

I was hoping to make it download to:
G:\2-18-05\SW Key Figures 2-18-05.snp

If the first mdofreport is left off it works fine, but when it is added a message:
...was not created because you do not have enough free disc space for temp work files.
I check both my C and server, and there is more than enough space in all folders called "Temp"



Thank you for any and all help!
 
We use the following for this exact same thing:

StrDate = Format(Date, "yyyy-MM") 'Can be used to format the date into any format you like...
'Output Report
DoCmd.OutputTo acReport, <i>"ReportName"</i>, acFormatSNP, "G:\Temp Reports Dir\Report1\" & "REPORT" & StrDate & ".snp"

It seems that from your code you are trying to name the report in both the ObjectName and the OutputFile aruments. Check that the Report name (Name of report within Access) is in the ObjectName...

Hope this helps!

Tim
 
Hello, a couple things. Change your date format to a string where you can use "-" instead of "/", which is an invalid character in a file name.

When you get the memory error, it usually means you have an invalid file name, not a memory problem.

You can use a routine like the one below to export to daily folders.

Dim myDir
Dim dirDate As String

dirDate = Format(Date, "mm-dd-yyyy")

MsgBox dirDate

myDir = Dir("C:\Temp\" & dirDate, vbDirectory)

If myDir = "" Then
'Directory does not exist - create

MkDir ("C:\Temp\" & dirDate)

End If


DoCmd.OutputTo acOutputReport, "SW Regional", acFormatSNP, "g:\" & dirDate & "\SW Key Figures " & mDofReport & ".snp"

Hope that helps, dRahme
 
dRahme's post works great, only have one question. When the button runs, a pop up box opens with OK only for the new folder. Is there any way around the pop-up? I have tried seting warnings off via code then via macro, but it does not work.

Any ideas?

Thank you for any and all help!
 
Hi, just comment out

' MsgBox dirDate

By placing an apostrophe in front of it

or delete it.

Message boxes are frequently used as a check to ensure your code is doing what it is supposed to.

dRahme
 
Thank you, after looking more closely at the code, I felt about 3" high asking that.. :)

However, here is one I tried solving but kept getting multiple errors.
After runing the code for a few days it has become clear that if I continue running it as is, there are going to soo many folders it would make a person sick....

Is there away to modify the code to go to:
G:\MONTH\2-18-05\SW Key Figures 2-18-05.snp

Here by if there is no folder with the current month it will make a folder with the month then go to the day folder. This way when researching the user could go to the G: pick the correct month and only have to search through 20 or so folders to find the correct day.



Thank you for any and all help!
 
A starting point:
dirName = "G:\" & Format(Date(), "yyyy-mm")
On Error Resume Next
MkDir dirName
On Error GoTo 0

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Try this:

Dim mydir, MyMonDir
Dim dirDate, dirMonth As String

dirMonth = Format(Date, "mmm")
dirDate = Format(Date, "mm-dd-yyyy")

MsgBox dirMonth

MyMonDir = Dir("C:\Temp\" & dirMonth, vbDirectory)

If MyMonDir = "" Then

'Create Month Directory

MkDir ("C:\Temp\" & dirMonth)

End If

mydir = Dir("C:\Temp\" & dirMonth & "\" & dirDate, vbDirectory)

If mydir = "" Then

'Need to create Day Directory
MkDir ("C:\Temp\" & dirMonth & "\" & dirDate)

End If


DoCmd.OutputTo acOutputReport, "SW Regional", acFormatSNP, "g:\" & dirMonth & "\" & dirDate & "\SW Key Figures " & mDofReport & ".snp"

dRahme
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top