How can I have this IIF query running?

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
 
O

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"
 

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