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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HELP! conditionals in queries 1

Status
Not open for further replies.

Joels7

MIS
May 1, 2001
9
US
In my query, for field name, I entered expr: last_date

Under condition I put in the following

If("paid"=("1J" Or "2"),6/30/01)

meaning if the paid field equals 1J or 2, the new field produced by the query should read 6/30/01. I am getting an error "Undefined function IF"

How must I do it differently?

Thank you,

JOels7
 
Create two queries, and run them seperatly.

eg,
SQL= "UPDATE DISTINCTROW Table SET Table.Field1 = #6/30/01# WHERE (((Table.Field2)=2));"
db.execute sql
SQL= "UPDATE DISTINCTROW Table SET Table.Field1 = #6/30/01# WHERE (((Table.Field2)=1]));"
db.execute Sql

Hunter
 
If this is in a query, then it needs to be IIF not IF
 

Use this syntax.

IIf([Paid]="1J" Or [Paid]="2", #6/30/01#, Null)

[li]You need the # to indicate that 6/30/01 is a date rather than a MATH expression.
[li]You need to include a False result for IIf - Null in my example.
[li]Use brackets around the column name. The string, "paid," is never equal to "1J" or "2". The column, [Paid], can be equal to one of those values.
[li]Access doesn't handle the syntax [Paid]="1J" Or "2". You must use [Paid]="1J" Or [Paid]="2". Terry L. Broadbent
Life would be easier if I had the source code. -Anonymous
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top