How can I have this IIF query running?

  • Thread starter Thread starter Oscar
  • Start date Start date
O

Oscar

This is my query :

strQuery = "SELECT DISTINCT ID_emp,name,adres,city, " _
& " sports = IIF(EXISTS(SELECT ID_sport FROM tblSports WHERE
ID_pers= tblArbCtr.persID), 1, 0)" _
& " FROM tblArbCtr,tblEmployee WHERE Contract = 0 AND
tblArbCtr.persID=tblEmployee.ID_emp"

I want to find out the employees who don't have a contract (contract=0)
first, and after that I want to verify whether they have a sport with the
derived 'sports' column. The compiler fires the following error : '3061 :
Too few parameters. expected 1'

Any idea how I need to change the query to have it running. I've already
checked the table and field names, they all are correct. Maybe it's a wrong
use of the IIF operator.

regards,
Oscar
 
I have it running now!
I needed to position the 'sports' field at the end : .... AS sports

strQuery = "SELECT DISTINCT ID_emp,name,adres,city, " _
& " IIF(EXISTS(SELECT ID_sport FROM tblSports WHERE ID_pers=
tblArbCtr.persID), 1, 0) AS sports " _
& " FROM tblArbCtr,tblEmployee WHERE Contract = 0 AND
tblArbCtr.persID=tblEmployee.ID_emp"
 
Back
Top