Adding a % via expression

  • Thread starter Anthony Viscomi
  • Start date
A

Anthony Viscomi

How do I add add (+) a % from within an expession?
Example:

$210 + -9% (negative 9%)=

Thanks,
Anthony
 
6

'69 Camaro

Hi, Anthony.

Your mathematical expression will need to multiply the amount by a value of
1.00 less the value of the percentage. For example:

$210.00 * (1.00 - 0.09) = $210.00 * 0.91 = $191.10

HTH.

Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address, so that a message
will be forwarded to me.)
 
A

Anthony Viscomi

I was actually intending on reading in the values from 2 controls:

BasePrice$ & Front% (Format = %)
 
6

'69 Camaro

Hi, Anthony.

Perhaps this example will help:

Me!txtDiscount.Value = Me!txtBasePrice.Value * (1.00 - (Me!txtFrontPct.Value
/ 100.00))

.... where txtBasePrice is the name of the text box displaying the base price
($210.00) and txtFrontPct is the name of the text box displaying the
percentage that you need to subtract from the base price (9%), and
txtDiscount is the name of the text box displaying the amount calculated
($191.10).

HTH.

Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address, so that a message
will be forwarded to me.)
 
A

Anthony Viscomi

Great...Thanks!
'69 Camaro said:
Hi, Anthony.

Perhaps this example will help:

Me!txtDiscount.Value = Me!txtBasePrice.Value * (1.00 - (Me!txtFrontPct.Value
/ 100.00))

... where txtBasePrice is the name of the text box displaying the base price
($210.00) and txtFrontPct is the name of the text box displaying the
percentage that you need to subtract from the base price (9%), and
txtDiscount is the name of the text box displaying the amount calculated
($191.10).

HTH.

Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address, so that a message
will be forwarded to me.)
 
A

Anthony Viscomi

I have the following code:

Dim intBaseTotal As Integer
Dim intDiscountTotal As Integer
Dim intFilter As String
intFilter = Me.ID
intBaseTotal = DSum("[Base_Price]", "tbl_OrderB", "[ID_B] =" &
[intFilter])
intDiscountTotal = intBaseTotal * (1# - (Me.Front_.Value / 100#))

Me.txtBasePriceTotal = intDiscountTotal

The intBaseTotal = $1465 and the Front_.Value = -9%..for some reason the end
result (intDiscountTotal) = $1466, which isn't correct. Any thoughts?
 
6

'69 Camaro

Hi, Anthony.

"Double negation" in an equation will add the value, and "double percenting"
will produce an answer 1/100th of the value. Your mathematical equation
should only apply the negation in one place and the percent operation in
only one place, too. Your equation is now applying the same mathematical
operations in two places, hence the wrong answer.

Either you can supply the whole number 9 (not -9%, which is a whole
different value, -0.09) in your Me.Front_ text box or you'll need to modify
the rest of the equation. If your algorithm is _always_ going to subtract
the percentage, then you should leave the equation as is and provide the
Me.Front value without a percent sign.

HTH.

Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address, so that a message
will be forwarded to me.)


Anthony Viscomi said:
I have the following code:

Dim intBaseTotal As Integer
Dim intDiscountTotal As Integer
Dim intFilter As String
intFilter = Me.ID
intBaseTotal = DSum("[Base_Price]", "tbl_OrderB", "[ID_B] =" &
[intFilter])
intDiscountTotal = intBaseTotal * (1# - (Me.Front_.Value / 100#))

Me.txtBasePriceTotal = intDiscountTotal

The intBaseTotal = $1465 and the Front_.Value = -9%..for some reason the end
result (intDiscountTotal) = $1466, which isn't correct. Any thoughts?
Anthony Viscomi said:
Great...Thanks!
message news:%[email protected]...
 
Top