Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 5030
  • Last Modified:

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

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
pmeloni
Asked:
pmeloni
  • 3
  • 3
  • 2
  • +2
2 Solutions
 
jadedataMS Access Systems CreatorCommented:
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
 
pmeloniAuthor Commented:
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
 
walterecookCommented:
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
pmeloniAuthor Commented:
2...
Surprising, there is just one field
0
 
walterecookCommented:
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
 
walterecookCommented:
BTW
Which version of access are we in here?
DAO? ADO?
0
 
pmeloniAuthor Commented:
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
 
stevbeCommented:
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
 
inoxCommented:

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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