OpenRecordset fails 3061

R

Rita

I have a statement:

Set rst = dbs.OpenRecordset(sql)

Where sql is a string with an SQL statement. It used to
work - but now all of a sudden it fails with the error Run-
time error 3061 "Too few parameters. Expected 1."

What has happened?

The SQL statement is working correctly in a query.
 
G

Graham R Seach

Rita,

To help us determine what's wrong, you should show us what's in sql, and if
it refers to any external objects, what and where those objects are.

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
 
G

Guest

Is there still a reference set to the DAO Library?
And is it refered to before the ADO one?

- Raoul
 
R

Rita

I would believe so - my references are:
Visual Basic for Applications
Microsoft Acces 9.0 Object Library
Microsoft DAO 3.6 Library
OLE Automation

I tried to rearrange - but without any luck. A slightly
older version of tha database works fine - with apparently
the same references and code.
 
G

Graham R Seach

Rita,

You'll answer a question that has nothing whatsoever to do with the problem,
but fail provide additional information when asked.

The error is: "Error 3061 - Too few parameters. Expected 1."

This relates to the SQL query itself, and specifically to its parameters. If
there was a References issue, the code would throw an error before it gets
to the recordset instantiation.

Now let's try this again. Show us the SQL query, and explain any external
objects referred to within it, what and where those objects are.

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
---------------------------
 
G

Guest

I'm getting this error too. I have tried using both a SQL statement, and
direct reference to a query - as you can see both lines of code are here. I
get the error either way, on the "db.Openrecordset" statement. The query
seems to run properply. Any suggestions here? THANKS!

'sSQL = "SELECT Employee.Employee FROM Employee INNER JOIN [Employee
Training] ON Employee.[Employee ID] = [Employee Training].empid WHERE
((([Employee Training].CriticalProgress)='Completed') AND (([Employee
Training].TrainingArea)=[Forms]![AdminSOP]![txtID]))"
Set db = CurrentDb()
Set rst = db.OpenRecordset("CStraining", dbOpenSnapshot)
'Set rst = db.OpenRecordset(sSQL, dbOpenSnapshot)
If rst.RecordCount > 0 Then
rst.MoveFirst
End If
Do Until rst.EOF
strNewTName = rst!Employee & " " & strDoc
Call TrainingDocs.ViewProcessDoc(strDoc, "Yes", , , "EditName",
, "No", strNewTName)
Loop
Set rst = Nothing
Set db = Nothing
 
G

Guest

I found it! Sorry... I believe the answer was in some of these previous
posts - but I just "misread", or read over, it! There was a form reference
in the query/sql. I needed to add it separately - sorry, don't have the
technical reference there!

Thanks anyway!

TRM said:
I'm getting this error too. I have tried using both a SQL statement, and
direct reference to a query - as you can see both lines of code are here. I
get the error either way, on the "db.Openrecordset" statement. The query
seems to run properply. Any suggestions here? THANKS!

'sSQL = "SELECT Employee.Employee FROM Employee INNER JOIN [Employee
Training] ON Employee.[Employee ID] = [Employee Training].empid WHERE
((([Employee Training].CriticalProgress)='Completed') AND (([Employee
Training].TrainingArea)=[Forms]![AdminSOP]![txtID]))"
Set db = CurrentDb()
Set rst = db.OpenRecordset("CStraining", dbOpenSnapshot)
'Set rst = db.OpenRecordset(sSQL, dbOpenSnapshot)
If rst.RecordCount > 0 Then
rst.MoveFirst
End If
Do Until rst.EOF
strNewTName = rst!Employee & " " & strDoc
Call TrainingDocs.ViewProcessDoc(strDoc, "Yes", , , "EditName",
, "No", strNewTName)
Loop
Set rst = Nothing
Set db = Nothing

Graham R Seach said:
Rita,

To help us determine what's wrong, you should show us what's in sql, and if
it refers to any external objects, what and where those objects are.

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top