Send to file problem

J

jman

I eventually intend to extend this to all forms in my database, but I will
use my specific form 'Mold Quotation Specification Sheet' to illustrate the
problem.

Basically, I'm trying to fill in some information in the form and then
create a report of it in a .rtf format. I have two buttons on my form. One is
to preview and print the report within Access and the other is to send the
report to a file to be emailed. The preview button works fine, but when I
generate a file using the button (I've tried .html, .rtf, and many others) it
only generates a blank report in the file regardless of what is in the form.

Here is the code for the preview button. I know it is probably not the most
efficient use of code, but it works in order to write the data to the table
and allow the report to preview correctly:

Private Sub CmdPreview_Click()
On Error GoTo Err_CmdPreview_Click

Dim FormName As String

FormName = "Mold Quotation Specification Sheet"
DoCmd.GoToRecord , , acNext
DoCmd.GoToRecord , , acPrevious
DoCmd.Save acForm, FormName

Dim stDocName As String

stDocName = "Mold Quotation Specification Sheet"
DoCmd.OpenReport stDocName, acViewPreview, , "[MoldQuoteSpecID]=" &
Me.[MoldQuoteSpecID]

Exit_CmdPreview_Click:
Exit Sub

Err_CmdPreview_Click:
MsgBox Err.Description
Resume Exit_CmdPreview_Click

End Sub



Here is the code for the malfunctioning send to report button:

Private Sub CmdSendToFile_Click()
On Error GoTo Err_CmdSendToFile_Click
Dim FormName As String

FormName = "Mold Quotation Specification Sheet"
DoCmd.GoToRecord , , acNext
DoCmd.GoToRecord , , acPrevious
DoCmd.Save acForm, FormName

Dim stDocName As String

stDocName = "Mold Quotation Specification Sheet"
DoCmd.OutputTo acReport, stDocName

Exit_CmdSendToFile_Click:
Exit Sub

Err_CmdSendToFile_Click:
MsgBox Err.Description
Resume Exit_CmdSendToFile_Click

End Sub
 

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