Avatar of Anil Lad
Anil Lad
Flag 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
Microsoft Access

Avatar of undefined
Last Comment
rockiroads

8/22/2022 - Mon
Rey Obrero (Capricorn1)

try

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

or

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

rockiroads

Use CLNG instead of CCur

same principle
jadedata

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.
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
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
rockiroads

Have u tried CDBL then?
Anil Lad

ASKER
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
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
GRayL

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.
Anil Lad

ASKER
I tried that (Format... "Fixed"....) but that left aligns data again.
Thxs
rockiroads

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
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
GRayL

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.
rockiroads

Try it on a query that formats your numbers?
Anil Lad

ASKER
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
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
ASKER CERTIFIED SOLUTION
rockiroads

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Anil Lad

ASKER
You're Awesome Rocki.  That worked!!  Can't believe it.
Thanks a tonne.!!
Thank you all for your assitance.
Anil
rockiroads

No probs :)