Link to home
Start Free TrialLog in
Avatar of Anil Lad
Anil LadFlag for Canada

asked on

Right align number values

Hi, another question,
 I have this sql, and want data to displayed right aligned.  But it's showing left align:
Quote Ratio for the Reporting Period: Format(IIf([Quoted]=0,0,Round((([Quoted]+[Declined])/[Quoted]),2)),"Fixed")

I had used CCur for premium,  but this field is a ratio so $ sign is not required.
Thanks.
Anil
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

try

CLng(IIf([Quoted]=0,0,Round((([Quoted]+[Declined])/[Quoted]),2)))

or

Int(IIf([Quoted]=0,0,Round((([Quoted]+[Declined])/[Quoted]),2)))

Use CLNG instead of CCur

same principle
i'm in a state of incredulity,... this question is practically a duplicate of the one you have yet to resolve on the very same matter.

Those are the same answers I posted on your last question.  And you stiffed me for the award because you'd rather have the cut/paste code.

cap/rock:  have fun building this guys application for him at 500 points a whack.  I'm not posting to any more of his until he reads the site rules and membership agreement.
Avatar of Anil Lad

ASKER

Jadedata
    Sorry, this is an overisght.  I did not intentionally stripped your award for the other question.
    It's just that I can't seem to think today.  As I was in rush, I just happend to look at the other answer which had ready code and I applied it and showed the result.     Don't worry, I will award you the points.  
    I posted this, thinking the other one was closed, that's why I stated I have a similar question.


Truly sorry.
Anil

Back to My question, the CLng is not working for me, I tired other ways, that's another reason I posted this question.
  My initial query gave  (left aligned),    
0.00
1.33
0.00

When I use CLng
Quote Ratio for the Reporting Period: CLng(Format(IIf([Quoted]=0,0,Round((([Quoted]+[Declined])/[Quoted]),2)),"Fixed"))
This is what I get:
0
1
0
Have u tried CDBL then?
Thanks. I tried Dbl, but this is what I get:
    0
1.33
    1

I am loosing two zero after the decimal cases where I have decmial zero zero.

Thx
Anil
Im running A2K and you cannot force a zero or an integer value to have trailing decimal zeros in a recordset.  You can, however, force a textbox on a form or a report to do so by making the format property fixed and selecting decimal places 2.
I tried that (Format... "Fixed"....) but that left aligns data again.
Thxs
I remember asking u this on your previous question
Are u using a form for this query?
If so, then use your query now (one that returns two dec places)

then on the form, the textbox that shows this value, ensure the property for that textbox "Text Align" is set to "Right"

that then will display your number right aligned

If not, then how are you using this query?

the fact that u use format, makes it into a string. Strings are left justified
I just created a simple form looking at one field of a small table with a variety of numbers 0,1.1,2.22,3.333,4

The format property of the textbox is set to Fixed and the number of decimals 2.  The default view property of the form is set to DataSheet.

I look at the data in datasheet view and I get:

0.00
1.10
2.22
3.33
4.00

all right aligned.  What can I say.
Try it on a query that formats your numbers?
I am not using forms.
This is strictly a query result, which users see.  
So I guess may be I cannot do this on a query result?
Thanks
Anil
ASKER CERTIFIED SOLUTION
Avatar of rockiroads
rockiroads
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You're Awesome Rocki.  That worked!!  Can't believe it.
Thanks a tonne.!!
Thank you all for your assitance.
Anil
No probs :)