Change header text with parameter

  • Thread starter Thread starter hermie
  • Start date Start date
H

hermie

I have 5 identical reports, the only difference in the reports is the text
in the Report Header data in details area is selected from a query with
parameter.

When I call the report a parameter asked for a number eg 1= agents 2 =
employers etc.

What I like to do is making 1 report and when the parameter is selected then
the header changes to the related parameter.

Is this possible to do?
 
hermie said:
I have 5 identical reports, the only difference in the reports is the text
in the Report Header data in details area is selected from a query with
parameter.

When I call the report a parameter asked for a number eg 1= agents 2 =
employers etc.

What I like to do is making 1 report and when the parameter is selected then
the header changes to the related parameter.


Very common thing to do. First, create a simple unbound
form where the user can use a combo box to select the
parameter value. Add a button to the form that opens the
report using the OpenReport method's WhereCondition argument
to filter the report (instead of using a parameter in the
query).

The report can then change the label's Caption in its Open
event:

Me.thelabel.Caption = Forms!theform.thecombo.Column(1)
 
Thanks for responding my question, but for me it is not common

I made an unbound form, and added an combobox with rowsource: SELECT
headertext.textheader FROM headertext;
this works. But i have problems to configure the commandbutton, where do i
need to put the openreport and whereCondition statement in the button?

Hope you can explain me more about the button procedure.

Herman
 
hermie said:
I made an unbound form, and added an combobox with rowsource: SELECT
headertext.textheader FROM headertext;
this works. But i have problems to configure the commandbutton, where do i
need to put the openreport and whereCondition statement in the button?

If you use the command button wizard to create the button
for opening a report, it will generate the basic code for
you. Then you only have to modify it a little to look like:

stCriteria = "thefield = " & thecombo
DoCmd.OpenReport stDoc, , , stCriteria

I notice that you have a single field in the combo box's
RowSource, you originally said that the parameter was a
number. This implies that the combo box should have both
the text and the number field in the query:

SELECT headernum, textheader FROM headertext

and the column count would then be 2, bound column 1, and
column widths 0;

But I could be wrong because you never have explained which
fields have what type values and how the combo data relates
to the main data table.
--
Marsh
MVP [MS Access]


 
I think I have to be more clear of what I want.

My table have fields for type, institucion and more other fields related to
data involved

Before I had for each institucion a separate table, now I have 1 table with
an added field named type to separate the data in a query with a parameter
eg criteria in query is:
[1= Agencia 2 = Patrono 3 = Institucion 4= Socio 5= Atendido]

Now I have 5 reports with 5 differents page headers and data

My wish is to create 1 report where it selects the data from the query
parameter and a page header selected from a table?
Not knowing if this is possible

BTW when I run the commandbutton wizard I not see openreport in the report
operation options?

Hope I was more clear now

Herman


Marshall Barton said:
hermie said:
I made an unbound form, and added an combobox with rowsource: SELECT
headertext.textheader FROM headertext;
this works. But i have problems to configure the commandbutton, where do i
need to put the openreport and whereCondition statement in the button?

If you use the command button wizard to create the button
for opening a report, it will generate the basic code for
you. Then you only have to modify it a little to look like:

stCriteria = "thefield = " & thecombo
DoCmd.OpenReport stDoc, , , stCriteria

I notice that you have a single field in the combo box's
RowSource, you originally said that the parameter was a
number. This implies that the combo box should have both
the text and the number field in the query:

SELECT headernum, textheader FROM headertext

and the column count would then be 2, bound column 1, and
column widths 0;

But I could be wrong because you never have explained which
fields have what type values and how the combo data relates
to the main data table.
--
Marsh
MVP [MS Access]


selected
then
 
Try Print Report or Preview Report command button wizard.

You kind of lost me with your description of the two (or is
it three) tables, I'm not even sure what you want the query
to do.

If the page header text is in a table, then you could also
retrieve it in a text box by using the DLookup function:
=DLookup("headertextfield", "thetable", "type=" &
forms!theform .thecombo)
--
Marsh
MVP [MS Access]


I think I have to be more clear of what I want.

My table have fields for type, institucion and more other fields related to
data involved

Before I had for each institucion a separate table, now I have 1 table with
an added field named type to separate the data in a query with a parameter
eg criteria in query is:
[1= Agencia 2 = Patrono 3 = Institucion 4= Socio 5= Atendido]

Now I have 5 reports with 5 differents page headers and data

My wish is to create 1 report where it selects the data from the query
parameter and a page header selected from a table?
Not knowing if this is possible

BTW when I run the commandbutton wizard I not see openreport in the report
operation options?
If you use the command button wizard to create the button
for opening a report, it will generate the basic code for
you. Then you only have to modify it a little to look like:

stCriteria = "thefield = " & thecombo
DoCmd.OpenReport stDoc, , , stCriteria

I notice that you have a single field in the combo box's
RowSource, you originally said that the parameter was a
number. This implies that the combo box should have both
the text and the number field in the query:

SELECT headernum, textheader FROM headertext

and the column count would then be 2, bound column 1, and
column widths 0;

But I could be wrong because you never have explained which
fields have what type values and how the combo data relates
to the main data table.
 
Back
Top