Changing Field Value Using Query

  • Thread starter Thread starter Joe
  • Start date Start date
J

Joe

I have 3 time fields in a table, MyTable: Time1, Time2,
Time3

I am using an update query with the following expression:

IIf([Time2]<[Time1], [Time2]=[Time3], [Time2])

Doesn't work. When, the expression is True, the Time2
field gets 12:00:00 AM, which is wrong data. I want it to
change the value of Time2 to be the same as Time3 if the
statement is True. Otherwise, if the expression is False,
don't change anything (this part works fine).

What am I doing wrong?
 
[Time2]=[Time3] will evaluate to either true/-1 or false/0. In either case,
the time value of the expression will be midnight (0).

I expect that if you are attempting to update Time2 with Time3 if Time2 >
Time1 then use
UPDATE tblYourTable
SET Time2 = Time3
WHERE Time2<Time1;
 
How lucky I must be...answered my own question again, at
least I think.

Should be:

IIf([Time2]<[Time1], [Time3], [Time2])

Right?
 
It's difficult to tell without seeing your full SQL view.

--
Duane Hookom
MS Access MVP


How lucky I must be...answered my own question again, at
least I think.

Should be:

IIf([Time2]<[Time1], [Time3], [Time2])

Right?
-----Original Message-----
I have 3 time fields in a table, MyTable: Time1, Time2,
Time3

I am using an update query with the following expression:

IIf([Time2]<[Time1], [Time2]=[Time3], [Time2])

Doesn't work. When, the expression is True, the Time2
field gets 12:00:00 AM, which is wrong data. I want it to
change the value of Time2 to be the same as Time3 if the
statement is True. Otherwise, if the expression is False,
don't change anything (this part works fine).

What am I doing wrong?
.
 
Back
Top