Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Format and the sort???

Status
Not open for further replies.

Phailak

Programmer
Apr 10, 2001
142
0
0
CA
Hail,

I have to 2 number fields which I want to display in a query with a calculation as Field1 / Field2 but instead of integers I want the field to show two decimals. So I thought I could use format(a,"0.00") or #.## but then when I put a sort on that field, it screws it up because it treats it as a text field (i.e. 11.50 comes before 9.50)
Am I just forgetting something, I have a feeling it's something really simple!

Phailak
 
You shouldn't really bother with how the numbers look in the query, cause you should not display the query to the users, they should only be able to view the data thru forms and reports, where you can use the format property of the textcontrol you're displaying this data in.

However, if you right click on the field (for instance in the field row of the query qrid), select properties, then you can also format the column in the query.

Roy-Vidar
 
Phailak,
You could just have the field twice in the query--once as formatted--this one with the 'Show' box checked, and a second time raw, ie just field1/field2, this one sorted and with the Show box unchecked.

Sure it's two calcs, but processor time is nothing--and the disk I/O to fetch the fields is done once no matter how many times you show it.
--Jim
 
Thanks! I formatted the field in the report but both were good suggestions!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top