Save Report to File

K

Kim

I have a form. From the form I want to be able to save
the report to a file based on certain criteria.

Below is the code that I currently have but when I try to
run it I get this error message " The format that you are
trying to out put is not currently available".


Private Sub cmdSave1_Click()
On Error GoTo Err_cmdSave1_Click

Dim strwhere As String

strwhere = "[bsdirID] = " & bsdirID

Dim stDocName As String

stDocName = "rptBattleStaffDirectives"
DoCmd.OutputTo acOutputReport, stDocName, acPreview,
strwhere


Exit_cmdSave1_Click:
Exit Sub

Err_cmdSave1_Click:
MsgBox Err.Description
Resume Exit_cmdSave1_Click

End Sub

Does the report have to be open before you can e-mail it
or save it to a file?

Thank you.
..
 
G

Guest

Hi,
acPreview is an invalid syntax for the Output to method.
Here's an example using for example rtf format

DoCmd.OutputTo acOutputTable, "Employees",
acFormatRTF, "Employee.rtf", True

true or false means if you want to open it or not.
hth
 

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

Top