Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, I have some tables in MS Access, I try to create new query under that particular table. I compare values from another table and joined here in this query. Am getting values in integer format(456, 567.3) but I need to show that values in decimal(456.00, 567.30). How to complete this task.

This is my sql query in Access table
SQL
SELECT 
      CustomerName, 
      OrderNumber, 
      InvoiceAmount, 
      (SELECT TotalPaid FROM InvoiceList WHERE InvoiceList.InvoiceId=NewInvoice_1.InvoiceId) AS AmountPaid, 
      (InvoiceAmount-Total) AS AmountDue,
      InvoiceStatus
FROM NewInvoice_1;
Output
SQL
CustomerName OrderNumber InvoiceAmount AmountPaid AmountDue Status
Galaxy       65412       6300.00       5000       1300      Paritally Paid
this InvoiceAmount is database column so it display as decimal, AmountPaid & AmountDue is query column but it display as Integer but i need to display as deciaml(5000.00 & 1300.00) how to do this ?

Thanks in advance,
Srihari
Posted

Try this:
SQL
format((InvoiceAmount-Total), "0.00") AS AmountDue

Read more: MS Access: Format Function (with Numbers)[^]
 
Share this answer
 
v3
Comments
srihari1904 22-Mar-14 5:41am    
Hi Thank you. working but in empty data's it showing error "#Error" like this ? how to solve it. That is "TotalPaid column is null for another Id" in this time access showing error "#Error"
Hi,

You could use a FORMAT function. In your case: FORMAT (Expression, "Fixed"). Fixed format is fixed to 2 decimal places (without thousand separator).

Your SQL should look like this:
SQL
SELECT
      CustomerName,
      OrderNumber,
      InvoiceAmount,
      FORMAT ((SELECT TotalPaid FROM InvoiceList WHERE InvoiceList.InvoiceId=NewInvoice_1.InvoiceId), "Fixed") AS AmountPaid,
      FORMAT ((InvoiceAmount-Total), "Fixed") AS AmountDue,
      InvoiceStatus
FROM NewInvoice_1;

Refer to: MS ACCESS: FORMAT FUNCTION (WITH STRINGS)[^]
 
Share this answer
 
v3
Comments
srihari1904 22-Mar-14 5:41am    
Thank you very much its working fine
Andrius Leonavicius 22-Mar-14 5:57am    
You're welcome. :)
srihari1904 22-Mar-14 7:58am    
Hi Thank you. working but in empty data's it showing error "#Error" like this ? how to solve it. That is "TotalPaid column is null for another Id" in this time access showing error "#Error"
Andrius Leonavicius 22-Mar-14 8:29am    
I think that FORMAT function should handle NULL values without error, but you can replace NULL values to 0 like this:
IIF(ISNULL(ColumnName),0,ColumnName)
srihari1904 24-Mar-14 6:36am    
Hi, Sorry am new to access how to make this query ?

IIF(ISNULL(AmountPaid),0,AmountPaid),
FORMAT ((SELECT TotalPaid FROM InvoiceList WHERE InvoiceList.InvoiceId=NewInvoice_1.InvoiceId), "Fixed") AS AmountPaid,

this code didn't working help me

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900