can one pass a parameter from a query to a report?

J

joel

I've written a query that prompts for the number of units being built
(N). It uses N as a multiplier to determine how many of each part is
needed, gets the difference between this and the number in stock and
produces a new field which is the number of parts we need to order, etc.

I then made a report using this query but I can't figure out how to get
this parameter N in it. All I can put in the report are the fields. Can
someone please tell me first, can I put N in the report (automatically
from the query)? If so, and it's easy, I'd appreciate a clue as to
how. If it's complex, just knowing it can be done will help a lot.
Right now I'm not sure I can actually do it.

Thanks
 
K

Ken Snell

Use a form for the entry of your parameter, then have the query read the
control on the form as the parameter; then your report can read the form's
control too to get the parameter.
 
F

Fredg

Joel,
If all you want to do is have the value of N print in the report, and if the
criteria of the query is set to something like:
[How many units]
then, in the report header, add an unbound control.
Set it's control source to:
= "There are " & [How many units] & " units being built."

The text within the brackets must be identical to the text within the query
brackets.
 
J

joel

Ken, thank you for the hints. I have no idea what you're talking about
but it appears I can achieve what I want. I'll try to understand your
words eventually.
Regards, Joel
 
J

joel

Fred, I don't know how a criterion can be [how many units] but I'm going
to try to find out. Thanks a lot for the tips. I've obviously got a
long way to go to figure out how this Access works.
Regards, Joel
Joel,
If all you want to do is have the value of N print in the report, and if the
criteria of the query is set to something like:
[How many units]
then, in the report header, add an unbound control.
Set it's control source to:
= "There are " & [How many units] & " units being built."

The text within the brackets must be identical to the text within the query
brackets.

--
Fred

Please reply only to this newsgroup.
I do not reply to personal e-mail.



I've written a query that prompts for the number of units being built
(N). It uses N as a multiplier to determine how many of each part is
needed, gets the difference between this and the number in stock and
produces a new field which is the number of parts we need to order, etc.

I then made a report using this query but I can't figure out how to get
this parameter N in it. All I can put in the report are the fields. Can
someone please tell me first, can I put N in the report (automatically
from the query)? If so, and it's easy, I'd appreciate a clue as to
how. If it's complex, just knowing it can be done will help a lot.
Right now I'm not sure I can actually do it.

Thanks
 
F

fgutkind

Fred, I don't know how a criterion can be [how many units] but I'm going
to try to find out. Thanks a lot for the tips. I've obviously got a
long way to go to figure out how this Access works.
Regards, Joel
Joel,
If all you want to do is have the value of N print in the report, and if the
criteria of the query is set to something like:
[How many units]
then, in the report header, add an unbound control.
Set it's control source to:
= "There are " & [How many units] & " units being built."

The text within the brackets must be identical to the text within the query
brackets.

--
Fred

Please reply only to this newsgroup.
I do not reply to personal e-mail.



I've written a query that prompts for the number of units being built
(N). It uses N as a multiplier to determine how many of each part is
needed, gets the difference between this and the number in stock and
produces a new field which is the number of parts we need to order, etc.

I then made a report using this query but I can't figure out how to get
this parameter N in it. All I can put in the report are the fields. Can
someone please tell me first, can I put N in the report (automatically
from the query)? If so, and it's easy, I'd appreciate a clue as to
how. If it's complex, just knowing it can be done will help a lot.
Right now I'm not sure I can actually do it.

Thanks
Joel,
re: >I've written a query that prompts for the number of units being
built (N) <
Open your query in design view.
Look at the criteria line for some sort of text that includes brackets
[ ].
My [How many units] is just a generic phrase. Your query criteria may
have different text. Whatever the text within the brackets is, that's
what you should use in the Report Header control, as indicated in my
previous reply.
Hope this clarifies things for you.
 
J

joel

Fred, I've tried what I think you are saying. I put what I think is an
unbound control at the top of my report with [number] in it. But
nothing happens, just the usual report.

I use [number] because that's what I put in the new field I created in
my query used in the report. The new field is
To_Order: [Quantity]*[number]-[In_Stock]

To_Order is the heading of the new field I guess.
[Quantity] and [In_Stock] refer to existing fields used in the query.

When I run this query or report I get prompted to enter [number]-- I
presume because this is the first time it's seen it. In any case, I
enter a number and sure enough, it's used correctly in the query.

But, I can't seem to get anything else in this system to recognize
number -- like in the report. It seems a shame to make a report based
on this [number] but it's value isn't reported.

So you see I remain confused on this.

Thanks, Joel
 
K

Ken Snell

OK - I see that you're following up with Fred in his related subthread. Let
me know if you want to pursue this idea further.
 
F

Fredg

joel said:
Fred, I've tried what I think you are saying. I put what I think is an
unbound control at the top of my report with [number] in it. But
nothing happens, just the usual report.

I use [number] because that's what I put in the new field I created in
my query used in the report. The new field is
To_Order: [Quantity]*[number]-[In_Stock]

To_Order is the heading of the new field I guess.
[Quantity] and [In_Stock] refer to existing fields used in the query.

When I run this query or report I get prompted to enter [number]-- I
presume because this is the first time it's seen it. In any case, I
enter a number and sure enough, it's used correctly in the query.

But, I can't seem to get anything else in this system to recognize
number -- like in the report. It seems a shame to make a report based
on this [number] but it's value isn't reported.

So you see I remain confused on this.

Thanks, Joel *** snipped ***

Joel,

re: > To_Order: [Quantity]*[number]-[In_Stock] <

OK, you're using [Number] in the query, but not as criteria.
That's where your prompt is coming from.

You left out an = sign in the Report header control.
This is still going to work in the Report Header, but you must place an
= sign in the control, not just [Number].

Again, in the Report Header, add an unbound control.
Set it's control source to:
= [Number]

The value you place when you run the report, when prompted for [Number],
will appear in the Report Header.

The query is the report's recordsource, isn't it? I hope.
 
J

joel

Fred, I got your last post and the equals sign does the trick. Now I
will try to get the prompt to actually prompt with something like "enter
the number of assemblies to be built...". Right now it just prompts for
the new parameter name. Lot's more to learn about this.
Thanks a lot for your help, Joel
Fred, I don't know how a criterion can be [how many units] but I'm
going to try to find out. Thanks a lot for the tips. I've obviously
got a long way to go to figure out how this Access works.
Regards, Joel
Joel,
If all you want to do is have the value of N print in the report, and
if the
criteria of the query is set to something like:
[How many units]
then, in the report header, add an unbound control.
Set it's control source to:
= "There are " & [How many units] & " units being built."

The text within the brackets must be identical to the text within the
query
brackets.

--
Fred

Please reply only to this newsgroup.
I do not reply to personal e-mail.



I've written a query that prompts for the number of units being built
(N). It uses N as a multiplier to determine how many of each part is
needed, gets the difference between this and the number in stock and
produces a new field which is the number of parts we need to order,
etc.

I then made a report using this query but I can't figure out how to get
this parameter N in it. All I can put in the report are the fields.
Can
someone please tell me first, can I put N in the report (automatically
from the query)? If so, and it's easy, I'd appreciate a clue as to
how. If it's complex, just knowing it can be done will help a lot.
Right now I'm not sure I can actually do it.

Thanks
 

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