expression into a field

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

hi
is there any way every time i type a currency value into a field [ticket]
into a form, this value to get increased plus [ticket]*10/100 ?
thanks
 
I think in your after-update event if you code something
like:

Me.MyField = Me.MyField * 0.1

That you'll get what you want.
 
yes thanks ...its Me.MyField = Me.MyField + Me.MyField * 0.1

Bill said:
I think in your after-update event if you code something
like:

Me.MyField = Me.MyField * 0.1

That you'll get what you want.


vassilis said:
hi
is there any way every time i type a currency value into a field [ticket]
into a form, this value to get increased plus [ticket]*10/100 ?
thanks
 
You could simplify:
Me.MyField = Me.MyField * 1.1

However, if the intention is to calculate a value based on the value of
MyField you should perform the calculation on the fly rather than storing
the calculated value, unless there is a specific reason why you need to save
the value at the time of the calculation.

vassilis said:
yes thanks ...its Me.MyField = Me.MyField + Me.MyField * 0.1

Bill said:
I think in your after-update event if you code something
like:

Me.MyField = Me.MyField * 0.1

That you'll get what you want.


vassilis said:
hi
is there any way every time i type a currency value into a field
[ticket]
into a form, this value to get increased plus [ticket]*10/100 ?
thanks
 
You could simplify:
Me.MyField = Me.MyField * 1.1

Careful about coercing the value to another data type e.g.

? TypeName(CCur(1234.56789) * 0.1)
returns 'Double'.

The OP probably wants to retain CURRENCY type e.g.

? TypeName(CCur(1234.56789) * CCur(0.1))
Currency

A different behaviour in SQL:

SELECT TYPENAME(CCUR(1234.5678) * 1.1)
returns 'Decimal'.

but the same approach i.e. consistent data type:

SELECT TYPENAME(CCUR(1234.5678) * CCUR(1.1))
returns 'Currency'.

Personally, I use DECIMAL for money data in Jet SQL anyhow :)

Jamie.

--
 

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

Back
Top