Ongoing recordset bits!

See attached. Note there is no actual data in the tables.

Click on frmExportPrepare.
Click "Export to Excel" on the frmExportPrepare.

This crashes with "Too Few Parameters" error on the following line.
Set rs = db.OpenRecordset("select distinct RepArea from qryExportPrepare01")

However, when I run the actual SQL it runs fine - with no error.

Help please!

Database1.accdb
Patrick O'DeaAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Systems AnalystCommented:
See the change regarding the EVAL ... wrap your Form's reference in eval with double quotes.

SELECT Format([credit_date],"yyyy") AS YearRange, Format([credit_date],"mm") AS MonthRange, credits2005b.CLAIM_MONTH, credits2005b.CREDIT_DATE, credits2005b.CREDIT, credits2005b.CREDIT_DATE, Merchants.MERCHANT_ID, Merchants.MERCHANT_NAME, MerchantGroups.MERCHANT_GROUP_NAME, Merchants.TOWN, Users.USER_GROUP, UserGroups.USER_GROUP_NAME, credits2005b.USER_ID, Users.USER_NAME, Users.TOWN, Users.RepArea, credits2005b.REBATE, credits2005b.SALES_VALUE, credits2005b.DISCOUNTPercent, credits2005b.REBATEPercent
FROM UserGroups INNER JOIN (Users INNER JOIN ((MerchantGroups INNER JOIN Merchants ON MerchantGroups.MERCHANT_GROUP = Merchants.MERCHANT_GROUP) INNER JOIN credits2005b ON Merchants.MERCHANT_ID = credits2005b.MERCHANT_ID) ON Users.USER_ID = credits2005b.USER_ID) ON UserGroups.USER_GROUP = Users.USER_GROUP
WHERE (((Format([credit_date],"yyyy"))=Eval("[forms]![frmExportPrepare]![YearNumber]")) AND ((Format([credit_date],"mm"))=Eval("[forms]![frmExportPrepare]![MonthNumber]")));
0
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Systems AnalystCommented:
see attached
Database1-MX01.zip
0
Patrick O'DeaAuthor Commented:
Thanks mx,

I am getting there but..

I could not open the zipped file you returned.
I got the message that the version of Access could not be detected and that the database was read only.

Can you resend?  (I am using A2010 but also have A2007)
0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Systems AnalystCommented:
sure ...stand by
0
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Systems AnalystCommented:
It opens fine for me ... A2010
Database1-MX01.accdb
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Patrick O'DeaAuthor Commented:
MX,

Got it open now and the error is gone.
However, when I run the VBA on my live confidential data there is no data found.
Presumably, because the SQL is not finding any.

Is there any way I can see the actual SQL being run.  I could then create a query to test.

If not I can create a small amount of dummy data.  (SLightler trickier than it sounds!)
0
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Systems AnalystCommented:
sure ... see image.  Set a Breakpoint at the places shown, click your export button. Code will break. Then in the Immediate window, you can show what the SQL is - I show two examples.

mx
Capture1.jpg
0
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Systems AnalystCommented:
Probably best to close this Q out if the original question was resolved, which I guess it is ?  Open a new Q if still having issue with SQL on real data ....

thx.mx
0
Patrick O'DeaAuthor Commented:
THanks MX,

I may well be back with another question.

I will investigate a few options first.

Thanks again
0
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Systems AnalystCommented:
You are welcome.  

mx
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.