RunTime error 3061

toleafs

Active Member
Joined
Jun 27, 2005
Messages
498
Hello
I am trying to get this code to work but I keep getting "Runtime error 3061, too few paramaters.Expected2. " Any ideas??? THANKS
Dim stDocName As String
Dim db As DAO.Database
Dim rs As DAO.Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("qsrcLetter", dbOpenSnapshot)
Set rs = db.OpenRecordset("qsrcCalcTbl_Orgn", dbOpenSnapshot)
Set rs = db.OpenRecordset("qsrcCalcTbl_Firm", dbOpenSnapshot)


Do Until rs.EOF

DoCmd.OpenReport stDocName, acPreview
DoCmd.SelectObject acReport, "rptL2005_02", True
DoCmd.PrintOut acPages, 1, 2
DoCmd.OpenReport stDocName, acPreview
DoCmd.SelectObject acReport, "rptt2005_05", True
DoCmd.PrintOut acPages, 1, 1
rs.MoveNext
Loop
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Why are you opening queries?

You don't seem to be doing anything with them except looping through.

And you are only looping though the last one you open and you don't refer to it within the loop apart from moving to the next record.

If you are getting that error then there is either a problem with your queries or a problem with the queries the reports are based on.

Do the queries you are opening have any connection to the reports?
 
Upvote 0
As you can probably tell, I am new to this coding "thing"
The queries are linked to a report. Effectively, what I want to do is Loop through the 2 reports by printing 2 pages from rptL2005_02 and 1 page from rptt2005_05 and continue this cycle until all records were printed.
 
Upvote 0
I don't think the problem is anything to do with the coding, though the code isn't really doing much.:)

The problem lies with the queries/reports and how you've set them up.

Are you expecting/wanting to use parameters?

Normally you would use them for user input but they could be used with a recordset to change the
results of the reports based on values from the results of the recordset.

For example say you had a table/query with the name of a customer and you wanted to print a separate report for each customer.

Then you could loop through a recordset containing the results from the query/table and use it's values as parameters.

If this is the sort of thing you want to do you could actually do it without code and without parameters.

All you would need to do would be to create a group in the report by customer or whatever.

You should end up with a report with all the customers, but with each customers data on separate pages.
 
Upvote 0

Forum statistics

Threads
1,215,425
Messages
6,124,826
Members
449,190
Latest member
rscraig11

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top