calculating a price in a report

J

JensC

Hello

I'm trying to make a report in which I want to print a price that is
calculated from other fields. Is that possible and how?

Regards
Jens
 
K

Klatuu

On both reports and forms, the Control Source property of a control
determines what is displayed in the control. To show a calculated value, you
just put the calculation in the control source property. This can be a
direct calculation or if it is complex, you can use a function. To use a
function, it has to be preceded with an equal sign. For example, if you had
a function you named CalcPrice, it would be:
=CalcPrice()

You can pass parameters to it as well.
 
J

JensC

Thank you for your answer

I want to use a function like You suggest. If I make a function, how do I
return the value?

My report is from a tabel called post. In this I have fields (itemno,
units). I have an other tabel called items with fields (itemno, itemprice)

My function CalcPrice() must return units * itemprice.

Is this possible?

Regards
Jens
 
K

Klatuu

Yes, it is possible, but you need to change the record source of your report
to include the other table. You could do it without adding the other table,
but it would be very slow because it would have to do database fetches for
every row.

You do that with a query that joins the two tables on itemno. Then you
don't need a function. All you would need in the control source of the price
would be:

=[units] * [itemprice]
 
J

JensC

Okay I understand about the query.

If I still want to use function, how do I do then. I would like to learn it.

Regards
Jens


Klatuu said:
Yes, it is possible, but you need to change the record source of your
report
to include the other table. You could do it without adding the other
table,
but it would be very slow because it would have to do database fetches for
every row.

You do that with a query that joins the two tables on itemno. Then you
don't need a function. All you would need in the control source of the
price
would be:

=[units] * [itemprice]
--
Dave Hargis, Microsoft Access MVP


JensC said:
Thank you for your answer

I want to use a function like You suggest. If I make a function, how do I
return the value?

My report is from a tabel called post. In this I have fields (itemno,
units). I have an other tabel called items with fields (itemno,
itemprice)

My function CalcPrice() must return units * itemprice.

Is this possible?

Regards
Jens
 
K

Klatuu

The function has to be in a standard module.
Then you reference the function as you would a calculated field in your
query. In design view it would be something like:

Price: CalcPrice([units], [itemprice])
--
Dave Hargis, Microsoft Access MVP


JensC said:
Okay I understand about the query.

If I still want to use function, how do I do then. I would like to learn it.

Regards
Jens


Klatuu said:
Yes, it is possible, but you need to change the record source of your
report
to include the other table. You could do it without adding the other
table,
but it would be very slow because it would have to do database fetches for
every row.

You do that with a query that joins the two tables on itemno. Then you
don't need a function. All you would need in the control source of the
price
would be:

=[units] * [itemprice]
--
Dave Hargis, Microsoft Access MVP


JensC said:
Thank you for your answer

I want to use a function like You suggest. If I make a function, how do I
return the value?

My report is from a tabel called post. In this I have fields (itemno,
units). I have an other tabel called items with fields (itemno,
itemprice)

My function CalcPrice() must return units * itemprice.

Is this possible?

Regards
Jens

"Klatuu" <[email protected]> skrev i en meddelelse
On both reports and forms, the Control Source property of a control
determines what is displayed in the control. To show a calculated
value,
you
just put the calculation in the control source property. This can be a
direct calculation or if it is complex, you can use a function. To use
a
function, it has to be preceded with an equal sign. For example, if
you
had
a function you named CalcPrice, it would be:
=CalcPrice()

You can pass parameters to it as well.
--
Dave Hargis, Microsoft Access MVP


:

Hello

I'm trying to make a report in which I want to print a price that is
calculated from other fields. Is that possible and how?

Regards
Jens
 
J

JensC

Hello

Thanks for your input. I will try it out.

Regards
Jens

Klatuu said:
The function has to be in a standard module.
Then you reference the function as you would a calculated field in your
query. In design view it would be something like:

Price: CalcPrice([units], [itemprice])
--
Dave Hargis, Microsoft Access MVP


JensC said:
Okay I understand about the query.

If I still want to use function, how do I do then. I would like to learn
it.

Regards
Jens


Klatuu said:
Yes, it is possible, but you need to change the record source of your
report
to include the other table. You could do it without adding the other
table,
but it would be very slow because it would have to do database fetches
for
every row.

You do that with a query that joins the two tables on itemno. Then you
don't need a function. All you would need in the control source of the
price
would be:

=[units] * [itemprice]
--
Dave Hargis, Microsoft Access MVP


:

Thank you for your answer

I want to use a function like You suggest. If I make a function, how
do I
return the value?

My report is from a tabel called post. In this I have fields (itemno,
units). I have an other tabel called items with fields (itemno,
itemprice)

My function CalcPrice() must return units * itemprice.

Is this possible?

Regards
Jens

"Klatuu" <[email protected]> skrev i en meddelelse
On both reports and forms, the Control Source property of a control
determines what is displayed in the control. To show a calculated
value,
you
just put the calculation in the control source property. This can
be a
direct calculation or if it is complex, you can use a function. To
use
a
function, it has to be preceded with an equal sign. For example, if
you
had
a function you named CalcPrice, it would be:
=CalcPrice()

You can pass parameters to it as well.
--
Dave Hargis, Microsoft Access MVP


:

Hello

I'm trying to make a report in which I want to print a price that
is
calculated from other fields. Is that possible and how?

Regards
Jens
 

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