• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 263
  • Last Modified:

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
0
Patrick O'Dea
Asked:
Patrick O'Dea
  • 7
  • 3
1 Solution
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
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 ArchitectCommented:
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
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
sure ...stand by
0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
It opens fine for me ... A2010
Database1-MX01.accdb
0
 
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 ArchitectCommented:
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 ArchitectCommented:
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 ArchitectCommented:
You are welcome.  

mx
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 7
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now