Solved

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

Posted on 2003-11-07
11
4,990 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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
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

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Join & Write a Comment

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

744 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