DoCmd.OutputTo

  • Thread starter Thread starter Opal
  • Start date Start date
O

Opal

Is it possible to code in VBA a parameter response in order to output
a report in
rich text format?
 
To send a report, use this command:

DoCmd.SendObject acSendReport, strReportname, acFormatRTF, strRecipient,
strCC, strBCC, strSubject, strMessage

The string variables can be populated however you want, either from the db,
from code, from the user, whatever.

The two constants, acSendReport, and acFormatRFT are the only things that
are literals.
 
To send a report, use this command:

DoCmd.SendObject acSendReport, strReportname, acFormatRTF, strRecipient,
strCC, strBCC, strSubject, strMessage

The string variables can be populated however you want, either from the db,
from code, from the user, whatever.

The two constants, acSendReport, and acFormatRFT are the only things that
are literals.






- Show quoted text -

Actually, that doesn't really help me. I am trying to Output a report
in rich text format not
send an object. The report is based on a query with the criteria
pointing to a combo box
on a form, i.e. user selects to view report and selects an area from a
drop down box on a
form then a report is created for that specific area. The criteria on
the query behind the
report is Forms![frmSelectArea]![cboArea]. If I use the
DoCmd.OutputTo, I get a parameter
pop-up for the Forms![frmSelectArea]![cboArea], I want to know if I
can use a code in
VBA that will provide this criteria and eliminate the pop-up.
 
On Wed, 30 Apr 2008 17:49:11 -0700 (PDT), Opal <[email protected]>
wrote:

Not if you use Docmd.OutputTo, UNLESS you actually have this form
frmSelectArea open and the combobox selected to the area of interest.

If that's not an option, you need a different query.

-Tom.
 
- Show quoted text -


To send a report, use this command:

DoCmd.SendObject acSendReport, strReportname, acFormatRTF, strRecipient,
strCC, strBCC, strSubject, strMessage

The string variables can be populated however you want, either from the
db,
from code, from the user, whatever.

The two constants, acSendReport, and acFormatRFT are the only things that
are literals.



Actually, that doesn't really help me. I am trying to Output a report
in rich text format not
send an object. The report is based on a query with the criteria
pointing to a combo box
on a form, i.e. user selects to view report and selects an area from a
drop down box on a
form then a report is created for that specific area. The criteria on
the query behind the
report is Forms![frmSelectArea]![cboArea]. If I use the
DoCmd.OutputTo, I get a parameter
pop-up for the Forms![frmSelectArea]![cboArea], I want to know if I
can use a code in
VBA that will provide this criteria and eliminate the pop-up.



How will the report know what Area to use, if the form isn't open?

Do you want a report with all Areas? If so, you should change the source of
the report's data, so that it references a query that does not have a
parameter.

If you know what Area to use, then you can use VBA to write a query that
only shows that Area, and use that query as the basis of your report.

Also, what do you mean by 'Output', if you don't want to send it? Are you
just trying to view it in Print Preview?
 
- Show quoted text -

To send a report, use this command:
DoCmd.SendObject acSendReport, strReportname, acFormatRTF, strRecipient,
strCC, strBCC, strSubject, strMessage
The string variables can be populated however you want, either from the
db,
from code, from the user, whatever.
The two constants, acSendReport, and acFormatRFT are the only things that
are literals.


Actually, that doesn't really help me.  I am trying to Output a report
in rich text format not
send an object.  The report is based on a query with the criteria
pointing to a combo box
on a form, i.e. user selects to view report and selects an area from a
drop down box on a
form then a report is created for that specific area.  The criteria on
the query behind the
report is Forms![frmSelectArea]![cboArea].   If I use the
DoCmd.OutputTo, I get a parameter
pop-up for the Forms![frmSelectArea]![cboArea], I want to know if I
can use a code in
VBA that will provide this criteria and eliminate the pop-up.

How will the report know what Area to use, if the form isn't open?

Do you want a report with all Areas?  If so, you should change the source of
the report's data, so that it references a query that does not have a
parameter.

If you know what Area to use, then you can use VBA to write a query that
only shows that Area, and use that query as the basis of  your report.

Also, what do you mean by 'Output', if you don't want to send it?  Are you
just trying to view it in Print Preview?

Yes, I know what area to use but unsure how to write a VBA query to
show only that area.

I am using the following statement once the area is known

DoCmd.OutputTo acOutputReport, "rptHourlyStatus", _
acFormatRTF, "C:\HourlyStatus.rtf", False

to output to a rtf document. My office uses Lotus Notes and
I have an email module which sends via Lotus Notes without
having to open the email program which the DoCmd.SendObject
does have to.
 
On Thu, 1 May 2008 16:36:50 -0700 (PDT), Opal <[email protected]>
wrote:

I maintain my position. You have a parameter query that refers to a
control on a form. If that form is open, Docmd.Outputto will work as
expected. If it is not, a parameter box will open. You don't like
that, but that's what Access has to do.

Workarounds include what I suggested: write a different query. Another
option may be to replace that parameter with: GetParameter()
This would be a public function in a standard module, and it would
return the original expression if the form is open, or the value that
you're stating you know the value of somehow.

-Tom.
 
I maintain my position. You have a parameter query that refers to a
control on a form. If that form is open, Docmd.Outputto will work as
expected. If it is not, a parameter box will open. You don't like
that, but that's what Access has to do.

Workarounds include what I suggested: write a different query. Another
option may be to replace that parameter with: GetParameter()
This would be a public function in a standard module, and it would
return the original expression if the form is open, or the value that
you're stating you know the value of somehow.

-Tom.

<clip>









- Show quoted text -

I'm sorry, did you respond before? I understand how Access works,
however, I want to run a parameter query in the background after a
table is updated and was hoping to run it in VBA with the code
"getting" the parameter based on the value updated in the table.

You state that "workarounds" would include what you suggested...
when was this?
 
I had previously written:
<begin>
Not if you use Docmd.OutputTo, UNLESS you actually have this form
frmSelectArea open and the combobox selected to the area of interest.

If that's not an option, you need a different query.
<end>

There is an elegant solution if you want to evaluate the value of a
parameter like Forms!SomeForm!SomeControl. Search groups.google.com
for "querydef parameter Eval" and you should find some examples.

-Tom.
 
Back
Top