Saving a report to "My Documents" (1 Viewer)

Cdogg

Registered User.
Local time
Today, 21:41
Joined
May 20, 2001
Messages
30
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

New member
Local time
Today, 21:41
Joined
Jan 24, 2002
Messages
8
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

Registered User.
Local time
Today, 21:41
Joined
May 20, 2001
Messages
30
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
 

Users who are viewing this thread

Top Bottom