Solved

Run-time error '3061': Too few parameters.Expected 2.

Posted on 2003-11-07
11
4,996 Views
Last Modified: 2007-12-19
this error apen at the last line of this code:

Public Function OpenFile(MyPath As String)

   Dim MyDatabase As Database
   Dim MyRecordSet1 As Recordset
   Dim MyRecordSet2 As Recordset
   Dim MyRecordSet3 As Recordset
   Dim MyRecordSet4 As Recordset
   Dim MyString As String
   
   Set MyDatabase = CurrentDb

   Set MyRecordSet1 = MyDatabase.OpenRecordset("Q_Export_File_1", dbOpenSnapshot)

The query by itself work find.

Thank's for your help
0
Comment
Question by:pmeloni
  • 3
  • 3
  • 2
  • +2
11 Comments
 
LVL 32

Accepted Solution

by:
jadedata earned 63 total points
ID: 9701507
Hey pmeloni!

  There is a field that cannot be resolved at command runtime in the query.
  copy the query as backup and then remove columns one-at-a-time until the error goes away
  The last column removed is the culprit.
 
  Posting the query would be a big help after you do the above.

regards
Jack
0
 

Author Comment

by:pmeloni
ID: 9701761
I change the query to the more simple possible:

SELECT [Cert Details].DetailID
FROM [Cert Details];

and I continue to have the message.

[Cert Details] is a table, not even a query.
0
 
LVL 17

Expert Comment

by:walterecook
ID: 9702032
pmeloni
When you changed to this:
SELECT [Cert Details].DetailID
FROM [Cert Details];
I understand that you still got the message but how many parameters is it looking for now?  2?  Or only 1?

Walt
0
 

Author Comment

by:pmeloni
ID: 9702240
2...
Surprising, there is just one field
0
 
LVL 17

Expert Comment

by:walterecook
ID: 9702328
Hmm
I'm curious to see if you changed the line to this, if it would open

Set MyRecordSet1 = MyDatabase.OpenRecordset("Cert Details", dbOpenSnapshot)

How about:
Set MyRecordSet1 = MyDatabase.OpenRecordset("Select * from [cert details]")

Walt
0
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
LVL 17

Expert Comment

by:walterecook
ID: 9702360
BTW
Which version of access are we in here?
DAO? ADO?
0
 

Author Comment

by:pmeloni
ID: 9702429
We are in Microsoft DAO3.6 Object Library

Using :
Set MyRecordSet1 = MyDatabase.OpenRecordset("Select * from [cert details]")
I get exactly the same error.

I'm using also as reference
Visual basic for application
Microsoft Access 11.0 Object library
Ole Automation
Microsoft calendar 11

I'm loosing my latin....

0
 
LVL 39

Assisted Solution

by:stevbe
stevbe earned 62 total points
ID: 9702773
do you get the same when you open the table manually? If you sorted on a column in the table and "saved" the changes then change the column name you would get the error yuou are seeing, while in design mode of the table, right click and clear the Fiter and OrderBy properties of the table itself.

Steve
0
 
LVL 4

Expert Comment

by:inox
ID: 9703820

make sure to use the DAO objects by
 Dim MyRecordSet1 As DAO.Recordset in contrast to
 ADODB.Recordset

(I'm not very convinced about my own answer because you'd get a different message (type-error) in that case, so don't shoot me if it's nonsense)
0
 
LVL 39

Expert Comment

by:stevbe
ID: 10025021
No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation for this question in the Cleanup topic area:

Split: jadedata {http:#9701507} & stevbe {http:#9702773}

Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

stevbe
EE Cleanup Volunteer
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now