Input mask troubles, convert into number?

jon jomaco

Registered User.
Local time
Today, 09:59
Joined
May 20, 2005
Messages
41
A field in one of my tables an input mask which means the user must enter a value into (__)%. Now when i run my invoice report i need the discount percentage to be taken from the total.

For this i could use the code:

GrandTotal = SubTotal - ((SubTotal/ 100) * (CompanyDiscount))

However, here lies the problem. The CompanyDiscount value is not stored as a number because of the input mask used so a mismatch error is produced - is there any way i can convert the value entered into the input mask to a number so if it was 10%, i could convert this value to 10 for instance?

Any help appreciated,
Jon.
 
Yea, i tried using val() previously but it just returns 0. I'm not sure why,
Jon.
 
What values do you have for discounts? Val() appears to only like whole numbers where there is a trailing %.

Try using CDbl(Left([MyDiscountField],Len([MyDiscountField])-1)
 
No worries i think i have sorted it by changing the default input mask generated by access. Thanks for your help, it seems to work without val() now, i believe it was something to do with the spaces at the end of the input mask.

In fact, yes, Val(CompanyDiscount) does have to be used; in any case it functions correctly now :)

Cheers,
Jon.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom