View Full Version : Saving a report to "My Documents"


Cdogg
01-10-2002, 05:20 AM
I want to save the reports to a folder in "My Documents". Can I push the File button and have it save using the LastName from the form or report as the filename so I don't have to go through 2 dialog boxes

Private Sub File_Click()
On Error GoTo Err_File_Click

Dim stDocName As String

stDocName = "MyForm"
DoCmd.OutputTo acReport, stDocName

Exit_File_Click:
Exit Sub

Err_File_Click:
MsgBox Err.Description
Resume Exit_File_Click

End Sub

Thank you for your help

GTrice
01-24-2002, 04:32 PM
Here try the following. Other than spaces it should work just fine.

Cheers

' Start Code

Private Sub File_Click()
On Error GoTo Err_File_Click

' This works if called from a form which has the value displayed that you want to print.

Dim xdir
xdir = "C:\My Documents\"

Dim xname
xname = [Forms]![Form Name]![Control Name]

Dim xtype
xtype = ".doc"

Dim stDocName As String
stDocName = xdir & xname & xtype

DoCmd.OutputTo acReport, stDocName

Exit_File_Click:
Exit Sub

Err_File_Click:
MsgBox Err.Description
Resume Exit_File_Click

End Sub

' end code

Cdogg
01-25-2002, 12:16 PM
Thank you for your help

I tried it with no luck

xname = [Forms]![Form Name]![Control Name]

I take it the Form Name is the name of the report.

The Control Name would be the text box with the Name I want it to be saved as.

What is Forms

Thank You