Cannot open recordset

L

Leslie Isaacs

Hello All

I have a module that includes the following line:

Set rstS = CurrentDb.OpenRecordset("qry_client_organisation_for_email",
dbOpenSnapshot)

All worked well while I was testing the module, during which I had a dummy
"qry_client_organisation_for_email", the sql for which was:
SELECT practices.[prac name], practices.live, Left([prac name],1) AS Expr1,
practices.email, Right([prac name],1) AS arg
FROM practices
WHERE (((Left([prac name],1))="a") AND ((practices.email) Like "*" &
"gppayroll" & "*") AND ((Right([prac name],1))="e"));

When I substitute the actual "qry_client_organisation_for_email" that I want
to use, and then run the process, I get:
Run-time error 3061. Too few parameters. Expected 1.
and the code stops on the following line:
Set rstS = CurrentDb.OpenRecordset("qry_client_organisation_for_email",
dbOpenSnapshot)

The sql for the actual "qry_client_organisation_for_email" is:
SELECT qryTotalDueByMonth.practice AS [prac name], qryTotalDueByMonth.email
FROM qryTotalDueByMonth
GROUP BY qryTotalDueByMonth.practice, qryTotalDueByMonth.email
HAVING (((qryTotalDueByMonth.practice)="Barms Medical Centre"));

This query runs fine from the main access window, so I cannot understand why
it seems to be a problem when I try to use it as the recordset.

Hope someone can help.

Many thanks
Leslie Isaacs
 
A

Alex Dybenko

Hi,
perhaps your original query qryTotalDueByMonth has a parameter, which refers
to form's control. Then you have to set this parameter when you open
recordset. see parameters collection in access help

--
Best regards,
___________
Alex Dybenko (MVP)
http://accessblog.net
http://www.PointLtd.com
 
L

Les Isaacs

Hello Alex

Thanks for your reply.

Unfortunately I will not now be in the office until Thursday (it's Tue
evening here in the UK now - not sure where/when you are!), so I cannot try
your suggestion until then. I will post back when I have done so to let you
know how I get on!

Thanks again.
Les



Alex Dybenko said:
Hi,
perhaps your original query qryTotalDueByMonth has a parameter, which
refers to form's control. Then you have to set this parameter when you
open recordset. see parameters collection in access help

--
Best regards,
___________
Alex Dybenko (MVP)
http://accessblog.net
http://www.PointLtd.com

Leslie Isaacs said:
Hello All

I have a module that includes the following line:

Set rstS = CurrentDb.OpenRecordset("qry_client_organisation_for_email",
dbOpenSnapshot)

All worked well while I was testing the module, during which I had a
dummy
"qry_client_organisation_for_email", the sql for which was:
SELECT practices.[prac name], practices.live, Left([prac name],1) AS
Expr1,
practices.email, Right([prac name],1) AS arg
FROM practices
WHERE (((Left([prac name],1))="a") AND ((practices.email) Like "*" &
"gppayroll" & "*") AND ((Right([prac name],1))="e"));

When I substitute the actual "qry_client_organisation_for_email" that I
want
to use, and then run the process, I get:
Run-time error 3061. Too few parameters. Expected 1.
and the code stops on the following line:
Set rstS = CurrentDb.OpenRecordset("qry_client_organisation_for_email",
dbOpenSnapshot)

The sql for the actual "qry_client_organisation_for_email" is:
SELECT qryTotalDueByMonth.practice AS [prac name],
qryTotalDueByMonth.email
FROM qryTotalDueByMonth
GROUP BY qryTotalDueByMonth.practice, qryTotalDueByMonth.email
HAVING (((qryTotalDueByMonth.practice)="Barms Medical Centre"));

This query runs fine from the main access window, so I cannot understand
why
it seems to be a problem when I try to use it as the recordset.

Hope someone can help.

Many thanks
Leslie Isaacs
 

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

Similar Threads

Too few parameters? 11
"Too few parameters" error - sometimes 1
ApplyFilter problem 2
Simply query? 9
What's wrong with this query?! 5
Function not known! 6
Ranking query 1
Slow query 13

Top