formatting percentages macro
The UK's Number 1 for Microsoft Office Training Add this page to your favourites/bookmarksBookmark page
 
View printable version of pagePrintable version
Plus One Google
Customer: Sign in
Delegate: Sign in
Trainer: Log in

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

replyReply Fri 11 Feb 2011, 10:37Delegate Andy said...

Andy has attended:
Access Introduction course
Access Intermediate 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

For upcoming training course dates see: Pricing & availability

replyReply Fri 11 Feb 2011, 10:51Trainer Anthony said...

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

replyReply Fri 11 Feb 2011, 11:28Delegate Andy said...

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

replyReply Fri 11 Feb 2011, 13:20Delegate Andy said...

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

 

Please browse our web site to find out more about
microsoft database training and other Microsoft training courses.

Access tip:

Create a custom Close button on a Form

By default, Forms that you create in Access have a full set of control buttons, that is, a title bar with Minimize, Maximize and Close buttons in the top right-hand corner and a Control Menu in the top left-hand corner.



Sometimes Access needs to follow certain procedures or events as users close a Form (such as automatically opening another Form perhaps). So it is often a good habit to create a custom Close button on a Form for everyone to use, rather than the standard closing cross.



To create a custom Close button:

1) In Form Design View, draw a Command Button onto the Form.

2) Use the Command Button Wizard to select Form Operations under Categories, and Close Form under Actions.

3) Choose Finish.



Access then creates the button and code to close the form for you. You can add any extra code that needs to run as the Form closes to the same Close procedure.



However, the creation of a custom Close button is pointless if the closing X in the top right-hand corner of the Form remains active. To make the closing X inactive, open the Form Properties box then on the Format tab set the Close Button setting to No. This will grey out the closing X leaving it visible, but inactive.



View all Access hints and tips


Microsoft Certified Partner Accredited Training Provider: Institute of IT Training Institute of Leadership and Management - Certified Courses Security Seal verified by visa, mastercard securecard