Solved

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

Posted on 2003-11-07
11
5,010 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 

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
 
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

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

733 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