Passing Variable to a report

  • Thread starter Thread starter Steve
  • Start date Start date
S

Steve

I have a label report that I would like to prgramtically
change just before running. I want to assign a variable
to the report and pass it in from my code. I have set it
up with a public variable and a text box with the
variable name. When I run the report I am prompted for
the parameters. HOw do I pass the info into the report
with out theprompting. When I enter into the prompt I
get what I want but I want to do this through
programming. THe user selects the option via a button. I
simply want to change the first line of a label
optionally without direct inputing. Thanks for any
insight.
 
Not following exactly what you're doing.

Are you using a form to enter the label caption into a textbox? And then
running the report by clicking a button on that form? Is the code to set the
report's caption in the report's module, or in the form's module?

A bit more info about your process, please.
 
Ken:

I have a form that is used to select andprint reports. I
have coded the print button to respond to an option
button which indicates if the user wants a certain line
of text to appear as the first line on each label. If
the line is asked for I am setting a variable with the
text called for and attempting to pass this variable to
the label report.

In english these are student address labels. In some
cases this text must appear on the first line "To THe
Parents or Guardian Of:". I suppose I could have two
seperate report formats but that seems wasteful. I
should be able to pass this informaiton to the report.
If the line is not asked for I was going to pass the
variable with just spaces. Make sense? I have worked
with other products and seomtimes Access frsutrates with
me with doing somehting that was relatively easy in other
packages. Thanks.
 
If you're using ACCESS 2002, you can pass the variable's value to the report
via the OpenArgs argument in the DoCmd.OpenReport action. It's the last
argument for the action, and works just like the OpenArgs argument in the
DoCmd.OpenForm action. Then, in the report's OnOpen event (you may need to
put it on an event that runs later than the Open event), you can set the
caption of the label using the OpenArgs method.

If you're using ACCESS 2000 or lower, you can use the report's OnOpen event
(see note above about a later event) to read the value from the form (use
the full reference to the form: [Forms]![FormName]![ControlName]) and set
the label's caption equal to this control's value.
 
Ken:

I am getting closer. I can trace that I am getting the
openargs variable over to the report module. However any
attempt to assign it to the text box fails. I get a
message that I can't assign a value to that object.
I am trying to place the value into the first box of text
on the label:

Me.firstlineoflabel= OpenArgs

This fails. Can you pointme in the right direction?
Thanks again
-----Original Message-----
If you're using ACCESS 2002, you can pass the variable's value to the report
via the OpenArgs argument in the DoCmd.OpenReport action. It's the last
argument for the action, and works just like the OpenArgs argument in the
DoCmd.OpenForm action. Then, in the report's OnOpen event (you may need to
put it on an event that runs later than the Open event), you can set the
caption of the label using the OpenArgs method.

If you're using ACCESS 2000 or lower, you can use the report's OnOpen event
(see note above about a later event) to read the value from the form (use
the full reference to the form: [Forms]![FormName]! [ControlName]) and set
the label's caption equal to this control's value.

--
Ken Snell
<MS ACCESS MVP>

Steve said:
Ken:

I have a form that is used to select andprint reports. I
have coded the print button to respond to an option
button which indicates if the user wants a certain line
of text to appear as the first line on each label. If
the line is asked for I am setting a variable with the
text called for and attempting to pass this variable to
the label report.

In english these are student address labels. In some
cases this text must appear on the first line "To THe
Parents or Guardian Of:". I suppose I could have two
seperate report formats but that seems wasteful. I
should be able to pass this informaiton to the report.
If the line is not asked for I was going to pass the
variable with just spaces. Make sense? I have worked
with other products and seomtimes Access frsutrates with
me with doing somehting that was relatively easy in other
packages. Thanks. Is
the code to set the set
it


.
 
Assuming that "firstlineoflabel" is a label control, you need to include
..Caption as part of the code:

Me.firstlineoflabel.Caption = Me.OpenArgs

--
Ken Snell
<MS ACCESS MVP>

Steve said:
Ken:

I am getting closer. I can trace that I am getting the
openargs variable over to the report module. However any
attempt to assign it to the text box fails. I get a
message that I can't assign a value to that object.
I am trying to place the value into the first box of text
on the label:

Me.firstlineoflabel= OpenArgs

This fails. Can you pointme in the right direction?
Thanks again
-----Original Message-----
If you're using ACCESS 2002, you can pass the variable's value to the report
via the OpenArgs argument in the DoCmd.OpenReport action. It's the last
argument for the action, and works just like the OpenArgs argument in the
DoCmd.OpenForm action. Then, in the report's OnOpen event (you may need to
put it on an event that runs later than the Open event), you can set the
caption of the label using the OpenArgs method.

If you're using ACCESS 2000 or lower, you can use the report's OnOpen event
(see note above about a later event) to read the value from the form (use
the full reference to the form: [Forms]![FormName]! [ControlName]) and set
the label's caption equal to this control's value.

--
Ken Snell
<MS ACCESS MVP>

Steve said:
Ken:

I have a form that is used to select andprint reports. I
have coded the print button to respond to an option
button which indicates if the user wants a certain line
of text to appear as the first line on each label. If
the line is asked for I am setting a variable with the
text called for and attempting to pass this variable to
the label report.

In english these are student address labels. In some
cases this text must appear on the first line "To THe
Parents or Guardian Of:". I suppose I could have two
seperate report formats but that seems wasteful. I
should be able to pass this informaiton to the report.
If the line is not asked for I was going to pass the
variable with just spaces. Make sense? I have worked
with other products and seomtimes Access frsutrates with
me with doing somehting that was relatively easy in other
packages. Thanks.
-----Original Message-----
Not following exactly what you're doing.

Are you using a form to enter the label caption into a
textbox? And then
running the report by clicking a button on that form? Is
the code to set the
report's caption in the report's module, or in the
form's module?

A bit more info about your process, please.

--
Ken Snell
<MS ACCESS MVP>

I have a label report that I would like to
prgramtically
change just before running. I want to assign a
variable
to the report and pass it in from my code. I have set
it
up with a public variable and a text box with the
variable name. When I run the report I am prompted for
the parameters. HOw do I pass the info into the report
with out theprompting. When I enter into the prompt I
get what I want but I want to do this through
programming. THe user selects the option via a
button. I
simply want to change the first line of a label
optionally without direct inputing. Thanks for any
insight.


.


.
 
Ken:

At home I had 2002 access and had this thing beat. At
work we are at 2000. SO, I am using the other method you
mentioned. Here is my code in the On report Open

Me.totheparentsof.Caption = Me.[Forms]![Report Menu]!
[firstlineoflabel]

Me.tothe...... is the control name of the first label text
box on the report. firstlineoflabel is a control on the
form that holds the text I wish to use. NOw, a stupid
question. Should these two text boxes be bound or
unbound? In any event when the code runs I receive the
message that the object does not support the argument or
method. Can you once again show me the errors of my
ways. THe openargs was very elegant but at work I don't
have that luxury. Your assitance is greatly appreciated.
[
-----Original Message-----
Assuming that "firstlineoflabel" is a label control, you need to include
..Caption as part of the code:

Me.firstlineoflabel.Caption = Me.OpenArgs

--
Ken Snell
<MS ACCESS MVP>

Steve said:
Ken:

I am getting closer. I can trace that I am getting the
openargs variable over to the report module. However any
attempt to assign it to the text box fails. I get a
message that I can't assign a value to that object.
I am trying to place the value into the first box of text
on the label:

Me.firstlineoflabel= OpenArgs

This fails. Can you pointme in the right direction?
Thanks again
-----Original Message-----
If you're using ACCESS 2002, you can pass the
variable's
value to the report
via the OpenArgs argument in the DoCmd.OpenReport action. It's the last
argument for the action, and works just like the OpenArgs argument in the
DoCmd.OpenForm action. Then, in the report's OnOpen event (you may need to
put it on an event that runs later than the Open
event),
you can set the
caption of the label using the OpenArgs method.

If you're using ACCESS 2000 or lower, you can use the report's OnOpen event
(see note above about a later event) to read the value from the form (use
the full reference to the form: [Forms]![FormName]! [ControlName]) and set
the label's caption equal to this control's value.

--
Ken Snell
<MS ACCESS MVP>

Ken:

I have a form that is used to select andprint reports. I
have coded the print button to respond to an option
button which indicates if the user wants a certain line
of text to appear as the first line on each label. If
the line is asked for I am setting a variable with the
text called for and attempting to pass this variable to
the label report.

In english these are student address labels. In some
cases this text must appear on the first line "To THe
Parents or Guardian Of:". I suppose I could have two
seperate report formats but that seems wasteful. I
should be able to pass this informaiton to the report.
If the line is not asked for I was going to pass the
variable with just spaces. Make sense? I have worked
with other products and seomtimes Access frsutrates with
me with doing somehting that was relatively easy in other
packages. Thanks.
-----Original Message-----
Not following exactly what you're doing.

Are you using a form to enter the label caption into a
textbox? And then
running the report by clicking a button on that
form?
Is
the code to set the
report's caption in the report's module, or in the
form's module?

A bit more info about your process, please.

--
Ken Snell
<MS ACCESS MVP>

I have a label report that I would like to
prgramtically
change just before running. I want to assign a
variable
to the report and pass it in from my code. I have set
it
up with a public variable and a text box with the
variable name. When I run the report I am
prompted
for
the parameters. HOw do I pass the info into the report
with out theprompting. When I enter into the prompt I
get what I want but I want to do this through
programming. THe user selects the option via a
button. I
simply want to change the first line of a label
optionally without direct inputing. Thanks for any
insight.


.



.


.
 
You are correct that ACCESS 2000 does not support OpenArgs for reports.

Change your code line to this:
Me.totheparentsof.Caption = [Forms]![Report Menu]![firstlineoflabel]

Don't use Me. in front of the forms reference.
--
Ken Snell
<MS ACCESS MVP>

Steve said:
Ken:

At home I had 2002 access and had this thing beat. At
work we are at 2000. SO, I am using the other method you
mentioned. Here is my code in the On report Open

Me.totheparentsof.Caption = Me.[Forms]![Report Menu]!
[firstlineoflabel]

Me.tothe...... is the control name of the first label text
box on the report. firstlineoflabel is a control on the
form that holds the text I wish to use. NOw, a stupid
question. Should these two text boxes be bound or
unbound? In any event when the code runs I receive the
message that the object does not support the argument or
method. Can you once again show me the errors of my
ways. THe openargs was very elegant but at work I don't
have that luxury. Your assitance is greatly appreciated.
[
-----Original Message-----
Assuming that "firstlineoflabel" is a label control, you need to include
..Caption as part of the code:

Me.firstlineoflabel.Caption = Me.OpenArgs

--
Ken Snell
<MS ACCESS MVP>

Steve said:
Ken:

I am getting closer. I can trace that I am getting the
openargs variable over to the report module. However any
attempt to assign it to the text box fails. I get a
message that I can't assign a value to that object.
I am trying to place the value into the first box of text
on the label:

Me.firstlineoflabel= OpenArgs

This fails. Can you pointme in the right direction?
Thanks again
-----Original Message-----
If you're using ACCESS 2002, you can pass the variable's
value to the report
via the OpenArgs argument in the DoCmd.OpenReport
action. It's the last
argument for the action, and works just like the
OpenArgs argument in the
DoCmd.OpenForm action. Then, in the report's OnOpen
event (you may need to
put it on an event that runs later than the Open event),
you can set the
caption of the label using the OpenArgs method.

If you're using ACCESS 2000 or lower, you can use the
report's OnOpen event
(see note above about a later event) to read the value
from the form (use
the full reference to the form: [Forms]![FormName]!
[ControlName]) and set
the label's caption equal to this control's value.

--
Ken Snell
<MS ACCESS MVP>

Ken:

I have a form that is used to select andprint
reports. I
have coded the print button to respond to an option
button which indicates if the user wants a certain line
of text to appear as the first line on each label. If
the line is asked for I am setting a variable with the
text called for and attempting to pass this variable to
the label report.

In english these are student address labels. In some
cases this text must appear on the first line "To THe
Parents or Guardian Of:". I suppose I could have two
seperate report formats but that seems wasteful. I
should be able to pass this informaiton to the report.
If the line is not asked for I was going to pass the
variable with just spaces. Make sense? I have worked
with other products and seomtimes Access frsutrates
with
me with doing somehting that was relatively easy in
other
packages. Thanks.
-----Original Message-----
Not following exactly what you're doing.

Are you using a form to enter the label caption into a
textbox? And then
running the report by clicking a button on that form?
Is
the code to set the
report's caption in the report's module, or in the
form's module?

A bit more info about your process, please.

--
Ken Snell
<MS ACCESS MVP>

I have a label report that I would like to
prgramtically
change just before running. I want to assign a
variable
to the report and pass it in from my code. I have
set
it
up with a public variable and a text box with the
variable name. When I run the report I am prompted
for
the parameters. HOw do I pass the info into the
report
with out theprompting. When I enter into the
prompt I
get what I want but I want to do this through
programming. THe user selects the option via a
button. I
simply want to change the first line of a label
optionally without direct inputing. Thanks for any
insight.


.



.


.
 
Back
Top