Changing Field Value Using Query

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?
 
D

Duane Hookom

[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;
 
G

Guest

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

Should be:

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

Right?
 
D

Duane Hookom

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?
.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top