Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another



Trying to run a parameterized query with this SQL

UPDATE PATIENT P
SET P.REGISTRATION_START_DATE =
(SELECT MAX(P2.REGISTRATION_START_DATE)
FROM PATIENT P2
WHERE P2.PATIENT_ID IN(?, ?))
WHERE P.PATIENT_ID = ?

And running in VBA like this:

cmdADO.Execute , Array(lNewPID, lOldPID, lNewPID), adExecuteNoRecords

This gives the above error.

When I do this:

UPDATE PATIENT P
SET P.REGISTRATION_START_DATE =
(SELECT MAX(P2.REGISTRATION_START_DATE)
FROM PATIENT P2
WHERE P2.PATIENT_ID IN(?, ?))
WHERE P.PATIENT_ID = " & lNewPID

cmdADO.Execute , Array(lNewPID, lOldPID), adExecuteNoRecords

It all runs fine.

Why is there a problem with the first method?


RBS

.