Calling report from form that uses Dlookup

L

Linda

I have a form that I have saved as a report. I would like to put a button on
the form to print the report. How do I launch the report from the form
button? There are some fields filled using DLookup on the form. They show
up as #Error on the report. What might be causing that? Also, how can I
limit the print to just the record the print report is selected in? Thanks
in advance for any help you can provide.
 
C

Carl Rapson

Linda said:
I have a form that I have saved as a report. I would like to put a button
on
the form to print the report. How do I launch the report from the form
button? There are some fields filled using DLookup on the form. They
show
up as #Error on the report. What might be causing that? Also, how can I
limit the print to just the record the print report is selected in?
Thanks
in advance for any help you can provide.

In the Click event of the button, call DoCmd.OpenReport:

DoCmd.OpenReport "name you gave the report"

To filter the report, specify the criteria in the WhereCondition parameter
of the OpenReport call:

DoCmd.OpenReport "name you gave the report",,,"[ID]=" & Me.ID

The field you use for the criteria should be the primary key of the record,
if possible. I used ID as a dummy field because I don't know the names of
your fields.

I'm not sure about the problem with DLookUp. I've never saved a form as a
report; I always create reports directly from my tables and queries. My
guess would be that the DLookUp calls are referring to a control or field
that is on the form but not on the report. What do your DLookUp calls look
like?

Carl Rapson
 
L

Linda

You are right in that the DLookup calls refer to a control on the form. In
reading one of the other threads they said the form controls would be
available to the report launched from the form. Here is an example of one of
my DLookup calls:
=DLookUp("[RequirementDescription]","[GBDRequirementsTbl]","[ReqNum] =
Forms!TestMatrixFrm![RequirementNumbertxt]")
--
Linda


Carl Rapson said:
Linda said:
I have a form that I have saved as a report. I would like to put a button
on
the form to print the report. How do I launch the report from the form
button? There are some fields filled using DLookup on the form. They
show
up as #Error on the report. What might be causing that? Also, how can I
limit the print to just the record the print report is selected in?
Thanks
in advance for any help you can provide.

In the Click event of the button, call DoCmd.OpenReport:

DoCmd.OpenReport "name you gave the report"

To filter the report, specify the criteria in the WhereCondition parameter
of the OpenReport call:

DoCmd.OpenReport "name you gave the report",,,"[ID]=" & Me.ID

The field you use for the criteria should be the primary key of the record,
if possible. I used ID as a dummy field because I don't know the names of
your fields.

I'm not sure about the problem with DLookUp. I've never saved a form as a
report; I always create reports directly from my tables and queries. My
guess would be that the DLookUp calls are referring to a control or field
that is on the form but not on the report. What do your DLookUp calls look
like?

Carl Rapson
 
C

Carl Rapson

As long as the form is still open, the controls should be available.
Unfortunately, I don't have any experience with referring to form controls
from a report; perhaps someone else does and can jump in here. One thing you
might try is to change it to look something like this:

=DLookUp("[RequirementDescription]","[GBDRequirementsTbl]","[ReqNum] = " &
Forms!TestMatrixFrm![RequirementNumbertxt])

In other words, concatenate the value from the form onto the string. I can't
guarantee this will work, however. Sorry I can't be of more help.

Carl Rapson

Linda said:
You are right in that the DLookup calls refer to a control on the form.
In
reading one of the other threads they said the form controls would be
available to the report launched from the form. Here is an example of one
of
my DLookup calls:
=DLookUp("[RequirementDescription]","[GBDRequirementsTbl]","[ReqNum] =
Forms!TestMatrixFrm![RequirementNumbertxt]")
--
Linda


Carl Rapson said:
Linda said:
I have a form that I have saved as a report. I would like to put a
button
on
the form to print the report. How do I launch the report from the form
button? There are some fields filled using DLookup on the form. They
show
up as #Error on the report. What might be causing that? Also, how can
I
limit the print to just the record the print report is selected in?
Thanks
in advance for any help you can provide.

In the Click event of the button, call DoCmd.OpenReport:

DoCmd.OpenReport "name you gave the report"

To filter the report, specify the criteria in the WhereCondition
parameter
of the OpenReport call:

DoCmd.OpenReport "name you gave the report",,,"[ID]=" & Me.ID

The field you use for the criteria should be the primary key of the
record,
if possible. I used ID as a dummy field because I don't know the names of
your fields.

I'm not sure about the problem with DLookUp. I've never saved a form as a
report; I always create reports directly from my tables and queries. My
guess would be that the DLookUp calls are referring to a control or field
that is on the form but not on the report. What do your DLookUp calls
look
like?

Carl Rapson
 

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