accessNator
Registered User.
- Local time
- Today, 15:23
- Joined
- Oct 17, 2008
- Messages
- 132
Here is a sample of a record from a table
Table_1
ref_Id, original_Ref_Id, sub_Total, rate_Multiplier, net_total
1, 0, 50, 0.0425, 2.125
2, 0, 120, 0.0425, 5.1
3, 1, 150, 0.0425, 6.375
My goal is to create a calculated field called final_Amt in a query based on two calculated columns. Here is my setup:
So my SQL query looks like this:
Select ref_Id, orig_Ref_Id, sub_Total, rate_Multiplier, net_Total, Round(net_Total,2) as current_Total, IIF(original_Ref_Id > 0, Round(DLookUp('net_Total', 'Table_1', 'ref_Id = ' & original_Ref_Id),2)) As original_Total from Table_1;
Everything works here as expected, but now I want to create a third calculated column based on the 2 calculated columns I just created and round the Amount to two decimal places.
The added criteria is:
If my original_Ref_Id column is greater than 0, then I create an IF statement condition to return an final_Amt column. So If the original_Ref_Id is greater than 0 then, current_Amount - original_Amount, otherwise current_Amount
The Query looks like this:
Select ref_Id, orig_Ref_Id, sub_Total, rate_Multiplier, net_Total, Round(net_Total,2) as current_Total, IIF(original_Ref_Id > 0, Round(DLookUp('net_Total', 'Table_1', 'ref_Id = ' & original_Ref_Id),2)) As original_Total , IIf([orig_Ref_Id] > 0,current_Total - original_Total], current_Total) AS final_Amt from Table_1;
But my final result, the final_Amt column which is a calculated column is not formatted properly. Instead of two decimal places based on my calculated columns, it goes out to at least 8 places in some of my records returned.
My question is how do I format my 3rd calculated column to always display 2 decimal places? I know I can format it in my properties setting in my Query grid IF i create the query from there, but in reality this Query will be created on demand using VB code.
If it helps, I can provide my VB code that creates the query.
Thanks in advance,
Chuck
Table_1
ref_Id, original_Ref_Id, sub_Total, rate_Multiplier, net_total
1, 0, 50, 0.0425, 2.125
2, 0, 120, 0.0425, 5.1
3, 1, 150, 0.0425, 6.375
My goal is to create a calculated field called final_Amt in a query based on two calculated columns. Here is my setup:
- I Round my net_Total as a new calculated column to two decimal places and call it current_Total.
- If the original_Ref_Id column is greater than 0 then I do a Dlookup function of the column original_Ref_Id which equals the value of the ref_Id and returns the respective net_Total as my NEW calculated original_Total column, and I would like to round it to two decimal places.
So my SQL query looks like this:
Select ref_Id, orig_Ref_Id, sub_Total, rate_Multiplier, net_Total, Round(net_Total,2) as current_Total, IIF(original_Ref_Id > 0, Round(DLookUp('net_Total', 'Table_1', 'ref_Id = ' & original_Ref_Id),2)) As original_Total from Table_1;
Everything works here as expected, but now I want to create a third calculated column based on the 2 calculated columns I just created and round the Amount to two decimal places.
The added criteria is:
If my original_Ref_Id column is greater than 0, then I create an IF statement condition to return an final_Amt column. So If the original_Ref_Id is greater than 0 then, current_Amount - original_Amount, otherwise current_Amount
The Query looks like this:
Select ref_Id, orig_Ref_Id, sub_Total, rate_Multiplier, net_Total, Round(net_Total,2) as current_Total, IIF(original_Ref_Id > 0, Round(DLookUp('net_Total', 'Table_1', 'ref_Id = ' & original_Ref_Id),2)) As original_Total , IIf([orig_Ref_Id] > 0,current_Total - original_Total], current_Total) AS final_Amt from Table_1;
But my final result, the final_Amt column which is a calculated column is not formatted properly. Instead of two decimal places based on my calculated columns, it goes out to at least 8 places in some of my records returned.
My question is how do I format my 3rd calculated column to always display 2 decimal places? I know I can format it in my properties setting in my Query grid IF i create the query from there, but in reality this Query will be created on demand using VB code.
If it helps, I can provide my VB code that creates the query.
Thanks in advance,
Chuck