Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Save Report to file and E-mail report from button on a Form 1

Status
Not open for further replies.

kimmer7389

Technical User
Nov 27, 2001
95
US
On a form I have 2 buttons. I would like for the the first button to allow users to e-mail a report based on the ID number of the form. I would like for the other button to allow them to save a report based on the criteria of the form.

This is the code I am trying to use to Save the report from the form.

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, acFormatSNP, strwhere


Exit_cmdSave1_Click:
Exit Sub

Err_cmdSave1_Click:
MsgBox Err.Description
Resume Exit_cmdSave1_Click

End Sub

This code dosen't work. I don't have the strwhere in the right place. I am not even sure if I am even close to making this work right.

Please Help.
 
What is "[bsdirID] = " & bsdirID ?
That doesn't look like it will work. The syntax just doesn't look right to me. Can you give us some details on what that represents.

Paul
 

What is "[bsdirID] = " & bsdirID ?

bsdirID is the name of the field that I want the snapshot file to save on.

If the bsdirID is "1" I want to save the snapshot file for record "1" only. I don't want to save all the records.
 
Well, the argument you have it in is not meant for that. The argument is the Path to the File you want to save the output to. That's what confused me about your syntax. The OutPutTo method doesn't use a Where argument. You will need to open the report and then save it. Try this.

Dim strDocName as String
Dim strWhere as String


strwhere = "[bsdirID] = " & bsdirID

stDocName = "rptBattleStaffDirectives"
Docmd.OpenReport strDocName,acViewPreview,,strWhere
DoCmd.OutputTo acOutputReport, stDocName, acFormatSNP, "C:\My Documents\MyDoc.snp"

See if that does it. You will need to modify the Path to the document you want to save the report to.

Paul

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top