Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Unwanted results from IIF statement

Status
Not open for further replies.

KristenCarr

Programmer
Oct 31, 2001
11
0
0
US
I'm using the following IIF statment in an Update query. The idea is to compare 2 dates (short date) in one table and insert a value into a third column in that same table.

It is not giving me errors but is inserting all 'C' values. The table only has 27 rows in it right now so I can easily see the results are incorrect.

IIf(([tblExportOfficeTEST]![date_added]>=[tblExportOfficeTEST]![last_updated]),"C","A")

I've tried the statement w/o the table names and that didn't help. I've used other statments and haven't ever had a problem, could it be related to these fields being DATE types?
 
Kristen -

I created a table called "tblMyDates". I put an Autonumber ID field in it, and then add a field called "Date" and "Last" and "NewField". Date and Last are date fields, formatted to short dates, and NewField is a text field.

I choose an "Update" Query and put in the "Update" window of the Field "NewField" the following line:

IIf([tblMyDates].[Date]>[tblMyDates].[Last],"C","A")

...and it worked just fine. May be the ! qualifier, didn't dig into that..anyway, that should work.
 
Thank you...it didn't work though. I can't even get the appropriate values in a Select statement.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top