Query not running from On Current Event

Ana2010

New member
Local time
Today, 08:02
Joined
Dec 4, 2010
Messages
8
Windows 7 Starter, Access 2007
I have the following query:
SELECT Sum(CobranzasAlquiler.ImporteCobrado) AS PagosDeuda
FROM CobranzasAlquiler
GROUP BY CobranzasAlquiler.IdContrato, CobranzasAlquiler.IdTipoCobro
HAVING (((CobranzasAlquiler.IdContrato)=Forms![Ex Contratos de Alquiler]!IdContrato) And ((CobranzasAlquiler.IdTipoCobro)="D"));
When run from the Query Designer it runs ok (If the Form [Ex Contratos de Alquiler] is opened in Form View the query "can see" the Forms![Ex Contratos de Alquiler]!IdContrato ), but when run from the On Current Event the error 3061 ("too few parameters , 1 expected") occurs!
Any suggestions??
 
Check to see if the column IdContrato is unticked
 
David, thanks for your quick reply!
I have just find a solution, I put the query in vba code with the following change:

strSQL = "SELECT Sum(CobranzasAlquiler.ImporteCobrado) AS PagosDeuda " & _
"FROM CobranzasAlquiler " & _
"GROUP BY CobranzasAlquiler.IdContrato, CobranzasAlquiler.IdTipoCobro " & _
"HAVING (((CobranzasAlquiler.IdContrato)= " & [Forms]![Ex Contratos de Alquiler]![IdContrato] & " )" & _
"AND ((CobranzasAlquiler.IdTipoCobro)='D'));"
 
David,
yes, IdTipoCobro and IdContrato were unticked.
 

Users who are viewing this thread

Back
Top Bottom