Button to Open Report

  • Thread starter Thread starter Dan
  • Start date Start date
D

Dan

I have a button on a form that is used to open a report.
The underlying query asks the user to enter the ID number
before generating the report. I would like the button to
open the report using the ID of the current record on the
form. What would be the code for this approach? Thanks.
 
Hi Dan

in the record source of the query that the report is based on put a criteria
for the ID field along the lines of

[Forms]![FRM_Name]![ID]

where FRM_Name is the name of the form with the button & ID shown on it

Cheers
JulieD
 
This can be done directly in your query design. On the
criteria line for the "ID" field that you're talking
about put:

Forms![YourFormName]![IDFieldName]

Note that the ID field has to be on the form that you're
using but it doesn't have to be visible to the user.
 
I have a button on a form that is used to open a report.
The underlying query asks the user to enter the ID number
before generating the report. I would like the button to
open the report using the ID of the current record on the
form. What would be the code for this approach? Thanks.

Change the query criteria from something like:
[Enter ID number]
to:
forms!FormName!ControlName

where the Form Name is the actual name of the form, and ControlName is
the name of the control displaying the ID number.
 
Julie,

I tried this previous to my post and I am getting
a 'Enter Parameter Box' rather than the report opening up.

Thanks,

Dan
-----Original Message-----
Hi Dan

in the record source of the query that the report is based on put a criteria
for the ID field along the lines of

[Forms]![FRM_Name]![ID]

where FRM_Name is the name of the form with the button & ID shown on it

Cheers
JulieD


I have a button on a form that is used to open a report.
The underlying query asks the user to enter the ID number
before generating the report. I would like the button to
open the report using the ID of the current record on the
form. What would be the code for this approach? Thanks.


.
 
Hi Dan

use the expression builder (on the toolbar) to build the criteria statement
again and let us know how you get on

Cheers
JulieD

Dan said:
Julie,

I tried this previous to my post and I am getting
a 'Enter Parameter Box' rather than the report opening up.

Thanks,

Dan
-----Original Message-----
Hi Dan

in the record source of the query that the report is based on put a criteria
for the ID field along the lines of

[Forms]![FRM_Name]![ID]

where FRM_Name is the name of the form with the button & ID shown on it

Cheers
JulieD


I have a button on a form that is used to open a report.
The underlying query asks the user to enter the ID number
before generating the report. I would like the button to
open the report using the ID of the current record on the
form. What would be the code for this approach? Thanks.


.
 
Julie,

Got it. Thanks!!!
-----Original Message-----
Julie,

I tried this previous to my post and I am getting
a 'Enter Parameter Box' rather than the report opening up.
Thanks,

Dan

-----Original Message-----
Hi Dan

in the record source of the query that the report is based on put a criteria
for the ID field along the lines of

[Forms]![FRM_Name]![ID]

where FRM_Name is the name of the form with the button
&
ID shown on it
Cheers
JulieD
button
.
 
Great!

Dan said:
Julie,

Got it. Thanks!!!
-----Original Message-----
Julie,

I tried this previous to my post and I am getting
a 'Enter Parameter Box' rather than the report opening up.
Thanks,

Dan

-----Original Message-----
Hi Dan

in the record source of the query that the report is based on put a criteria
for the ID field along the lines of

[Forms]![FRM_Name]![ID]

where FRM_Name is the name of the form with the button
&
ID shown on it
Cheers
JulieD


I have a button on a form that is used to open a report.
The underlying query asks the user to enter the ID number
before generating the report. I would like the
button
to
open the report using the ID of the current record on the
form. What would be the code for this approach? Thanks.




.
.
 
If the control is on the same form as the command button
running the report, the following syntax would be much
more robust:

DoCmd.OpenReport "rptVendorBid", acViewPreview, , "[BidID]
= " & Me.BidID

This makes use of the WHERECONDITION clause of the
OpenReport command. That way you don't have to hard-code
the criteria into the query, and can run the report
directly without the filter, if you choose to.

DS
-----Original Message-----
I have a button on a form that is used to open a report.
The underlying query asks the user to enter the ID number
before generating the report. I would like the button to
open the report using the ID of the current record on the
form. What would be the code for this approach? Thanks.

Change the query criteria from something like:
[Enter ID number]
to:
forms!FormName!ControlName

where the Form Name is the actual name of the form, and ControlName is
the name of the control displaying the ID number.
--
Fred
Please only reply to this newsgroup.
I do not reply to personal email.
.
 
Back
Top