98.7% Of all customers recommend us, we're so confident about our results we publish all reviews and stats
View Live Stats View ReviewsForum home » Delegate support and help forum » Microsoft Access Training and help » Formatting percentages in a macro
Formatting percentages in a macro
Resolved · High Priority · Version 2007
Andy has attended:
Access Introduction course
Access Intermediate course
Access Advanced course
Access Advanced course
Formatting percentages in a macro
Hi
I'm building a conditional macro that automatically enters data into fields in a form when certain other conditions are met. For example, the condition is a loan APR%= 0% And the loan term = 12 months; the action is Setvalue; the argument is Lender deduction = 5.10%.
This macro does what I want it to do for 0% by changing it to "0" in the condition, but if I change the % to say 9.90% it will not work. I have tried all the variations I can think of eg. 9.90, 9.9, 0.0990 etc - but it jusr will not work. I'm sure it is something to do with how access recognises percentages but if just run out of ideas.
Anyboby got any ideas i can try?
N.B. the Loan APR % field is formatted as a percent field.
Thanks
Andy
RE: formatting percentages in a macro
Hi Andy, thanks for your query. I suspect the field you are sending the data to is formatted with the default Number datatype, which is a Long Integer - and integers are always, by definition, whole numbers. Try changing the datatype of the field to a Short or Double number instead.
Hope this helps,
Anthony
RE: formatting percentages in a macro
Hi Anthony
It was already set to double, so changed it to single but it made no difference unfortunately.
If you have any other thoughts i'd be glad to hear them.
regards
Andy
RE: formatting percentages in a macro
Hi Anthony
I have found the solution. I changed the data field to general number to see how Access formatted percentages as a general number, then changed the field back to percent. I then replicated the format in my macro and it worked!
Probably wouldn't have thought of it without your initial response - so thanks.
Regards
Andy
Training information:
See also:
Welcome. Please choose your application (eg. Excel) and then post your question. Our Microsoft Qualified trainers will then respond within 24 hours (working days). Frequently Asked Questions
Any suggestions, questions or comments? Please post in the Improve the forum thread. |
Access tip:Undo Entries In RecordsTo Undo any entries or changes in records: |