Update Queries

  • Thread starter Thread starter james Read
  • Start date Start date
J

james Read

This is driving me crazy. I have a simple update to make.
I have a table with MileFrom and MileTo as long integer. I
need the difference to be updated to TotalMiles in the
same table. I run a select query and change to update. I
ran this the first time and it worked fine, modified some
data and ran it again to test and second time round the
query just returns nulls. In the field column I have
TotalMiles, in the update to coulumn of the update query I
have TotalMiles = ([MileTo])-([MileFrom]).

Can anyone spot where I'm going wrong?

Thanks in advance.
 
Is there ever a case where the TotalMiles field could validly be different
than [MileTo] - [MileFrom] ?

If not, you must not store this field. Use a query to calculate it. For an
example, see:
Calculated fields
at:
http://allenbrowne.com/casu-14.html

(The article also explains how to do it if you want to store the value
anyway.)
 
Back
Top