SendObject doesn't find fields in querry

J

J.Bennett

I have a form that has a button to run an "event Procedure" to preview a
report, and to email the report as a pdf attachment. The codes I use are as
follows:

Private Sub emailfullpricesheet_Click()

DoCmd.OpenReport "Full Price Sheet", acViewPreview, , , acWindowNormal
DoCmd.SendObject acSendReport, "Full Price Sheet", acFormatPDF, , , ,
[DLRName], _
"Thank You for your business.", True

End Sub

In this code, I have the field for the dealer name (shown above as
[DLRName]) where it would be placed in the subject line. However, when I run
this button with any field name included, I get an error message as follows:

Run-time error '2465'
Microsoft Office Access can't find the filed '|' referenced in our expression.

The field name is correct. I have even tried other field names from the
query. Additionally, this field name is on the report produced in the first
commad of the event procedure and the report is displayed correctly.

Can anyone help with what I am doing wrong that prevents fields from being
displayed? Otherwise, I can simply use an embedded Macro. However, I want
the ability to reference the specific dealer information.

Any help would be greatly appreciated.

Frustrated!!!!!
 
R

Rick Brandt

J.Bennett said:
I have a form that has a button to run an "event Procedure" to preview a
report, and to email the report as a pdf attachment. The codes I use are
as follows:

Private Sub emailfullpricesheet_Click()

DoCmd.OpenReport "Full Price Sheet", acViewPreview, , , acWindowNormal
DoCmd.SendObject acSendReport, "Full Price Sheet", acFormatPDF, , , ,
[DLRName], _
"Thank You for your business.", True

End Sub

In this code, I have the field for the dealer name (shown above as
[DLRName]) where it would be placed in the subject line. However, when I
[run
this button with any field name included, I get an error message as
follows:

Run-time error '2465'
Microsoft Office Access can't find the filed '|' referenced in our
expression.

The field name is correct. I have even tried other field names from the
query. Additionally, this field name is on the report produced in the
first commad of the event procedure and the report is displayed correctly.

Can anyone help with what I am doing wrong that prevents fields from being
displayed? Otherwise, I can simply use an embedded Macro. However, I
want the ability to reference the specific dealer information.

SendObject has no access to any of the fields in the report. Code within
the report's own events can access field data but SendObject is running
external to the report and has no "knowledge" of the data the report is
using.
 

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