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!

iif statement issue

Status
Not open for further replies.

access101

Programmer
Sep 4, 2010
68
0
0
US
I have an access database back end and I'm trying to use this iif statement iif(schedule.type like '%p%', staff.rate1, staff.rate2). But I keep getting the error that the like statement is not recognized.
 
Hi,

Please post your code.

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
That's all I have it's new table adapter I created with two tables from access one table is called sched which has a column named Type the other is called staff which has a column called rate1 and rate2 the table is joined by employee column.
 
Oh...Ok sorry the table is called sched not schedule I missed typed it in my post.
 

so now your iif() statement works, yes?

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
post your code please, as it currently runs.

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
SELECT DISTINCT Staff.Employee, Staff.Rate1, Staff.Rate2, Sched.Type,iif([sched].[type] like 'P', staff.rate2, iif([sched].[type] not like 'P', staff.rate1)) as exp2

FROM (Sched RIGHT OUTER JOIN
Staff ON Sched.Employee = Staff.Employee)
GROUP BY Staff.Employee, Staff.Rate1, Staff.Rate2, Sched.Type
 
Why not sched.type?


Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 

Code:
SELECT DISTINCT
  Staff.Employee
, Staff.Rate1
. Staff.Rate2
, Sched.Type
, iif(sched.type like '%P%', staff.rate2, staff.rate1) as exp2

FROM (Sched RIGHT OUTER JOIN
Staff ON Sched.Employee = Staff.Employee)

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
i just tried the code in query builder and the do results show but it still says error in list function arguments: 'LIKE' not recognized. Unable to parse query text
 
Try * rather than %

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
nope still not working. im using query builder. i don't know if that matters?
 
I would try:

SQL:
SELECT DISTINCT
  Staff.Employee
, Staff.Rate1
, Staff.Rate2
, Sched.Type
, iif(sched.type like "*P*", staff.rate2, staff.rate1) as exp2

FROM (Sched RIGHT OUTER JOIN
Staff ON Sched.Employee = Staff.Employee)

Are you running this totally in an Access application or is there a different "front-end"?

If this doesn't work, please be more descriptive with what results you are getting.

Duane
Hook'D on Access
MS Access MVP
 
I found the issue in access I had a query with two tables that were not joined. Is there way to fix that. The two tables don't have any columns that I can join
 
How would you logically join these two?

Would a cartisian join be appropriate?

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top