Multiply a field

E

Eric

I would like to have a field be mulitplied by a set number and that number be
stored in another field, for example:
We copy medical records and charge a .75 cents per page. What I would like
to do is that when the number of copies is entered into field it will be
times by the .75 cents and display the result/fee for the copies in another
field.
Thanks,
Eric
 
K

Klatuu

It would not be correct to store the calculation. Doing so violates a basic
database normalization rule. The correct method is to perform the
calculation whenever you need to present the information to a user either on
a form or report. The how to is to use a unbound text box and do the
calculation in its Control Source property:

=[txtPageCount] * 0.75

Where txtPageCount is the control on your form (forms don't have fields,
they have controls. Fields are properties of tables and queries).
 
A

Arvin Meyer [MVP]

A small piece of code in the AfterUpdate event:

Sub txtPageCount_AfterUpdate()
If IsNumeric(Me.txtPageCount) Then
Me.txtCopyCharge = Me.txtPageCount * 0.75
End If
End Sub

I'd also add a line of code to the form's Current event:

Sub Form_Current()
txtPageCount_AfterUpdate
End Sub
 
E

Eric

Thank you. I did as you suggested and it worked! Thanks! However, I would
like the fee amount to be stored in the table as well. Is there a way to go
about that. If it only calculates on the form or a report then it will not
be part of the record correct?
Thanks,
Eric

Klatuu said:
It would not be correct to store the calculation. Doing so violates a basic
database normalization rule. The correct method is to perform the
calculation whenever you need to present the information to a user either on
a form or report. The how to is to use a unbound text box and do the
calculation in its Control Source property:

=[txtPageCount] * 0.75

Where txtPageCount is the control on your form (forms don't have fields,
they have controls. Fields are properties of tables and queries).
--
Dave Hargis, Microsoft Access MVP


Eric said:
I would like to have a field be mulitplied by a set number and that number be
stored in another field, for example:
We copy medical records and charge a .75 cents per page. What I would like
to do is that when the number of copies is entered into field it will be
times by the .75 cents and display the result/fee for the copies in another
field.
Thanks,
Eric
 
J

Jeff Boyce

Eric

Actually, I suspect you need another table that holds "fee-for-timeperiod"
data. After all, when you change your fee, you'll want to use the new
amount, but be able to see how much used to be charged, right?

Regards

Jeff Boyce
Microsoft Office/Access MVP

Eric said:
Thank you. I did as you suggested and it worked! Thanks! However, I
would
like the fee amount to be stored in the table as well. Is there a way to
go
about that. If it only calculates on the form or a report then it will
not
be part of the record correct?
Thanks,
Eric

Klatuu said:
It would not be correct to store the calculation. Doing so violates a
basic
database normalization rule. The correct method is to perform the
calculation whenever you need to present the information to a user either
on
a form or report. The how to is to use a unbound text box and do the
calculation in its Control Source property:

=[txtPageCount] * 0.75

Where txtPageCount is the control on your form (forms don't have fields,
they have controls. Fields are properties of tables and queries).
--
Dave Hargis, Microsoft Access MVP


Eric said:
I would like to have a field be mulitplied by a set number and that
number be
stored in another field, for example:
We copy medical records and charge a .75 cents per page. What I would
like
to do is that when the number of copies is entered into field it will
be
times by the .75 cents and display the result/fee for the copies in
another
field.
Thanks,
Eric
 
E

Eric

I think I may have worded the question badly, the fee itself cannot change
unless NYS says it can change, however I think I want the actual charge, i.e.
we sent 100 pages at .75 = $75.00 to be stored in the table. If I do as
suggested, the charge amount will not be stored in the record. Do you have
a suggestion with that or maybe I do not need to have the charge amount saved
as we always know it is going to be #pages x .75?
Thanks,
Eric

Jeff Boyce said:
Eric

Actually, I suspect you need another table that holds "fee-for-timeperiod"
data. After all, when you change your fee, you'll want to use the new
amount, but be able to see how much used to be charged, right?

Regards

Jeff Boyce
Microsoft Office/Access MVP

Eric said:
Thank you. I did as you suggested and it worked! Thanks! However, I
would
like the fee amount to be stored in the table as well. Is there a way to
go
about that. If it only calculates on the form or a report then it will
not
be part of the record correct?
Thanks,
Eric

Klatuu said:
It would not be correct to store the calculation. Doing so violates a
basic
database normalization rule. The correct method is to perform the
calculation whenever you need to present the information to a user either
on
a form or report. The how to is to use a unbound text box and do the
calculation in its Control Source property:

=[txtPageCount] * 0.75

Where txtPageCount is the control on your form (forms don't have fields,
they have controls. Fields are properties of tables and queries).
--
Dave Hargis, Microsoft Access MVP


:

I would like to have a field be mulitplied by a set number and that
number be
stored in another field, for example:
We copy medical records and charge a .75 cents per page. What I would
like
to do is that when the number of copies is entered into field it will
be
times by the .75 cents and display the result/fee for the copies in
another
field.
Thanks,
Eric
 
J

Jeff Boyce

The general "rule" (use that term loosely) is that anything you can
calculate from existing (stored) values doesn't need to be stored itself.
That said, there may be occasions when you decide to store, say, the
[SalesAmount] because the price-per-unit can be different from one time to
another. My suggestion about using a table to keep "charges-at-timerange"
would be a way to NOT have to store [SalesAmount], because that value could
always be calculated from:

* Qty
* Unit price-at-point-in-time (between Date1 and Date2 of the daterange
during which the price was in effect).

That method lets you keep a price history, and calculate what someone had
been charged back in '03...<g>

Good luck!

Regards

Jeff Boyce
Microsoft Office/Access MVP

Eric said:
I think I may have worded the question badly, the fee itself cannot change
unless NYS says it can change, however I think I want the actual charge,
i.e.
we sent 100 pages at .75 = $75.00 to be stored in the table. If I do as
suggested, the charge amount will not be stored in the record. Do you
have
a suggestion with that or maybe I do not need to have the charge amount
saved
as we always know it is going to be #pages x .75?
Thanks,
Eric

Jeff Boyce said:
Eric

Actually, I suspect you need another table that holds
"fee-for-timeperiod"
data. After all, when you change your fee, you'll want to use the new
amount, but be able to see how much used to be charged, right?

Regards

Jeff Boyce
Microsoft Office/Access MVP

Eric said:
Thank you. I did as you suggested and it worked! Thanks! However, I
would
like the fee amount to be stored in the table as well. Is there a way
to
go
about that. If it only calculates on the form or a report then it will
not
be part of the record correct?
Thanks,
Eric

:

It would not be correct to store the calculation. Doing so violates a
basic
database normalization rule. The correct method is to perform the
calculation whenever you need to present the information to a user
either
on
a form or report. The how to is to use a unbound text box and do the
calculation in its Control Source property:

=[txtPageCount] * 0.75

Where txtPageCount is the control on your form (forms don't have
fields,
they have controls. Fields are properties of tables and queries).
--
Dave Hargis, Microsoft Access MVP


:

I would like to have a field be mulitplied by a set number and that
number be
stored in another field, for example:
We copy medical records and charge a .75 cents per page. What I
would
like
to do is that when the number of copies is entered into field it
will
be
times by the .75 cents and display the result/fee for the copies in
another
field.
Thanks,
Eric
 
E

Eric

The more I thought about it, I agree with the general "rule" why do we need
to store it when we already know what it is by calcuating...so thanks and I
have updated my forms and records per you suggestion.
Thanks,
Eric

Jeff Boyce said:
The general "rule" (use that term loosely) is that anything you can
calculate from existing (stored) values doesn't need to be stored itself.
That said, there may be occasions when you decide to store, say, the
[SalesAmount] because the price-per-unit can be different from one time to
another. My suggestion about using a table to keep "charges-at-timerange"
would be a way to NOT have to store [SalesAmount], because that value could
always be calculated from:

* Qty
* Unit price-at-point-in-time (between Date1 and Date2 of the daterange
during which the price was in effect).

That method lets you keep a price history, and calculate what someone had
been charged back in '03...<g>

Good luck!

Regards

Jeff Boyce
Microsoft Office/Access MVP

Eric said:
I think I may have worded the question badly, the fee itself cannot change
unless NYS says it can change, however I think I want the actual charge,
i.e.
we sent 100 pages at .75 = $75.00 to be stored in the table. If I do as
suggested, the charge amount will not be stored in the record. Do you
have
a suggestion with that or maybe I do not need to have the charge amount
saved
as we always know it is going to be #pages x .75?
Thanks,
Eric

Jeff Boyce said:
Eric

Actually, I suspect you need another table that holds
"fee-for-timeperiod"
data. After all, when you change your fee, you'll want to use the new
amount, but be able to see how much used to be charged, right?

Regards

Jeff Boyce
Microsoft Office/Access MVP

Thank you. I did as you suggested and it worked! Thanks! However, I
would
like the fee amount to be stored in the table as well. Is there a way
to
go
about that. If it only calculates on the form or a report then it will
not
be part of the record correct?
Thanks,
Eric

:

It would not be correct to store the calculation. Doing so violates a
basic
database normalization rule. The correct method is to perform the
calculation whenever you need to present the information to a user
either
on
a form or report. The how to is to use a unbound text box and do the
calculation in its Control Source property:

=[txtPageCount] * 0.75

Where txtPageCount is the control on your form (forms don't have
fields,
they have controls. Fields are properties of tables and queries).
--
Dave Hargis, Microsoft Access MVP


:

I would like to have a field be mulitplied by a set number and that
number be
stored in another field, for example:
We copy medical records and charge a .75 cents per page. What I
would
like
to do is that when the number of copies is entered into field it
will
be
times by the .75 cents and display the result/fee for the copies in
another
field.
Thanks,
Eric
 

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