OutputTo custom filename run time error 3011

Ste4en

Registered User.
Local time
Today, 00:37
Joined
Sep 19, 2001
Messages
142
I have used the code below to run a report to our server. I need to change the file name each time to be date specific. When I run the code I get run time error 3011 - Microsoft Jet Database Engine could not find object".

When I get that solved - the query that the report runs from requires a date input which should be yesterdays date - what line of code can I enter to do that.

Private Sub Option7_Click()


Dim outputSNP As Variant

outputSNP = "j:\umps\this week\" & "Clock Hours for-" & Format(Now(), "yyyymmdd") & ".snp"
DoCmd.OutputTo acReport, "DailyClockReport -All Employees", acFormatSNP, outputSNP, False

MsgBox "the report is published to " & outputSNP

End Sub


Thanks
 
Use

Dim outputSNP As String

instead of:

Dim outputSNP As Variant

That's whats expected so why not provide it.

Also use the below for yesterdays date

outputSNP = "j:\umps\this week\" & "Clock Hours for-" & Format(DateAdd("d", -1, Date), "yyyymmdd") & ".snp"
 
Thanks - I tried it but no change...this is the updated version.


Dim outputSNP As String

outputSNP = "j:\umps\this week\" & "Clock Hours for-" & Format(DateAdd("d", -1, Date), "yyyymmdd") & ".snp"
DoCmd.OutputTo acReport, "DailyClockReport -All Employees", acFormatSNP, outputSNP, False

THanks
 
Don't know what version you're running, but shouldn't the first OutputTo argument be acOutputReport instead of acReport?
 
Whoops, spoke too soon

Apologies,

Please ignore my last remarks - the constants are both equal to '3' according to Object Browser.
 

Users who are viewing this thread

Back
Top Bottom