* cBatchNo would be the parameter * I also would have liked to get the result in a variable instead of a cursor * but that has so far eluded me Local nResult AS Integer, cSql AS String Text To cSql Noshow Select Sum(Amount) AS Amount from dbo.CreditorInvoices Where BatchNo = ?cBatchNo Group By BatchNo EndText nResult = SQLExec(lnSql,cSql,'TempAmount')>Hi Peter,