formatting percentages macro

Forum home » Delegate support and help forum » Microsoft Access Training and help » Formatting percentages in a macro

Formatting percentages in a macro

resolvedResolved · 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


 

Access tip:

Undo Entries In Records

To Undo any entries or changes in records:

Hit the ESC key once for the current field

And ESC twice for current record

View all Access hints and tips


Server loaded in 0.09 secs.