I'm trying to get the following simplified test query to work so that I can
apply it to a more complex final query.
I get a 'Too few parameters' error when I try to run the following append
query:
Dim db as DAO.Database, qd as DAO.QueryDef, prm as DAO.Parameter
Set db = Currentdb
Set qd = db.QueryDefs("aaTest")
For Each prm In qd.Parameters
prm.Value = Eval(prm.Name)
Next
db.Execute "aaTest", dbFailOnError
The SQL for aaTest is:
INSERT INTO tArrearsGrouped ( LAN, Amount)
SELECT tIncome.LAN, Sum(tIncome.AmtRec) AS SumOfAmtRec
FROM tIncome
GROUP BY tIncome.LAN
HAVING (((tIncome.LAN)=[Forms]![fTenantDetails]![LAN]));
fTenantDetails is open when the query is run, and the correct value is found
in 'For each...'.
For the final query, the parameter is buried in a right join of a query
within a query, so I cannot apply a simple 'WHERE' condition to the
db.Execute. ie the parameter needs to be applied at the level of that query.
If I convert AATest to a select query, I can open a recordset on it, so I
must be getting at least part of it right(I think).
Any ideas appreciated.
--
Bob Darlington
Brisbane