How to change neg calc'd value to a pos value?

  • Thread starter Thread starter Punice
  • Start date Start date
P

Punice

The following creates the correct values in the querie, but with a negative
connotation. How do I change the sign?

SELECT State_Mileage_Table.M_ID, State_Mileage_Table.M_TracNo,
State_Mileage_Table.M_SerNo, State_Mileage_Table.M_Date,
State_Mileage_Table.M_State, State_Mileage_Table.M_Odom,
[State_Mileage_Table]![M_Odom]-DLookUp("[M_Odom]",
"State_Mileage_Table","[M_SerNo]-0.01=" & [M_SerNo]) AS M_Traveled
FROM State_Mileage_Table
ORDER BY State_Mileage_Table.M_SerNo;
 
If you want to strip of the negative use the abs function

Abs([State_Mileage_Table]![M_Odom]-
DLookUp("[M_Odom]","State_Mileage_Table","[M_SerNo]-0.01=" & [M_SerNo])) AS
M_Traveled

Or if it is always negative then reverse the calculation

DLookUp("[M_Odom]","State_Mileage_Table","[M_SerNo]-0.01=" & [M_SerNo]) -
[State_Mileage_Table]![M_Odom] AS M_Traveled

John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
 
Bless you, John Spencer. After trying to solve my sign changing problem for
about a week, I took the easy out and asked the World for help. The 'Abs()'
method worked. I tried using it before, but didn't get the 'abs' or parens
in the correct spots. Now, thanks to you, I understand how those functions
are applied. I'll test
the second method that you provided, later. I need to finish the project,
first.
punice
 
Back
Top