OutPutTo Issues - HELP

G

Guest

I have the following code that I'm hoping to have generate an Excel
Spreadsheet based on a query that I have. When I run it as is, I get an error
saying that:

Microsoft Office Access can't save the data to the output file you've
selected.

If I change stName to something like test.xls it works fine.

Begin 1 and End1 are simple functions that get the beginning and ending
dates for the current reporting period.

Function CCReport1()
On Error GoTo CCReport1_Err
Dim stName As String
stName = "Client Corp - " & Begin1 & " - " & End1 & ".xls"
DoCmd.SetWarnings False
DoCmd.OpenQuery "qryMTRsrcHour12Week", acViewNormal, acEdit
DoCmd.OpenQuery "qryMTRsrc", acViewNormal, acEdit
DoCmd.OpenQuery "qryMTAppMgmt", acViewNormal, acEdit
DoCmd.OpenQuery "qryMTAppMgmtRsrcHours", acViewNormal, acEdit
DoCmd.OpenQuery "qryOvh", acViewNormal, acEdit
DoCmd.OpenQuery "qryProjHours", acViewNormal, acEdit
' DoCmd.OpenQuery "Rpt 1 - App Mgmt Grp 1", acViewNormal, acEdit
DoCmd.OutputTo acOutputQuery, "Rpt 1 - App Mgmt Grp 1", acFormatXLS,
stName, True
DoCmd.SetWarnings True
CCReport1_Exit:
Exit Function
CCReport1_Err:
MsgBox Error$
Resume CCReport1_Exit
End Function

Public Function Begin1() As Date
Dim Beg1 As Date
Beg1 = DateAdd("d", -8, Date)
Begin1 = Beg1
End Function

Public Function End1() As Date
Dim End_1 As Date
End_1 = DateAdd("d", -2, Date)
End1 = End_1
End Function
 
G

Guest

Doh!!! Nevermind - Yes I am a bonehead... It wasn't working becuase I did not
reformat the dates and you can't have file names with "/"...
 

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

The below code isn't working. Please help. 5
Error 20 Resume without Error 2
Object required error 4
Import File 1
Run Time Error #3021 1
Access 2002 versus 2000 1
VBA Code 1
Error 2391 5

Top