Error 3061

L

.Len B

The following is in the OnOpen event of a form. It is designed to
populate an ocx control in the form.

Dim rst As Recordset, stSelCrit As String
stSelCrit = "SELECT NoteDate, LogonName, CNote FROM selqNotes"
stSelCrit = stSelCrit & " ORDER BY NoteDate DESC;"
Set rst = CurrentDb.OpenRecordset(stSelCrit)
The Set rst = statement generates the error:
Too few parameters. Expected 1. (3061)

It used to work but stopped working after I added a new combo to
the form. I can't see how that caused it.

It says it is expecting 1 paramater. By my count it is getting
one, just one.

I changed this
Dim rst As DAO.Recordset, ...
and doublechecked that References include MS DAO 3.6 Object Library.

What else might it be?
 
K

Krzysztof Naworyta

..Len B wrote:
| The following is in the OnOpen event of a form. It is designed to
| populate an ocx control in the form.
|
| Dim rst As Recordset, stSelCrit As String
| stSelCrit = "SELECT NoteDate, LogonName, CNote FROM selqNotes"
| stSelCrit = stSelCrit & " ORDER BY NoteDate DESC;"
| Set rst = CurrentDb.OpenRecordset(stSelCrit)
| The Set rst = statement generates the error:
| Too few parameters. Expected 1. (3061)
|
| It used to work but stopped working after I added a new combo to
| the form. I can't see how that caused it.
|
| It says it is expecting 1 paramater. By my count it is getting
| one, just one.


What is your selqNotes ?
Is it another query, that has references to any form control?

If so, use querydef object and evqaluate your parameter:

Dim qr as QueryDef
Dim pr as parameter

set qr = currentDb.CreateQueryDef("", stSelCrit)
For each pr in qr.Parameters
pr.Value = Eval(pr.Name)
Next

Set rst = qr.OpenRecordset
 
L

.Len B

| .Len B wrote:
|| The following is in the OnOpen event of a form. It is designed to
|| populate an ocx control in the form.
||
|| Dim rst As Recordset, stSelCrit As String
|| stSelCrit = "SELECT NoteDate, LogonName, CNote FROM selqNotes"
|| stSelCrit = stSelCrit & " ORDER BY NoteDate DESC;"
|| Set rst = CurrentDb.OpenRecordset(stSelCrit)
|| The Set rst = statement generates the error:
|| Too few parameters. Expected 1. (3061)
||
|| It used to work but stopped working after I added a new combo to
|| the form. I can't see how that caused it.
||
|| It says it is expecting 1 paramater. By my count it is getting
|| one, just one.
|
|
| What is your selqNotes ?
| Is it another query, that has references to any form control?
|
| If so, use querydef object and evqaluate your parameter:
|
| Dim qr as QueryDef
| Dim pr as parameter
|
| set qr = currentDb.CreateQueryDef("", stSelCrit)
| For each pr in qr.Parameters
| pr.Value = Eval(pr.Name)
| Next
|
| Set rst = qr.OpenRecordset
|
| ---
| KN

selqNotes is a select query without parameters.

SELECT Child.ChildID, Child.FamilyNum, Child.Surname,Child...,
Note.NoteDate, Note.CNote, Note.LogonName, Note.ContactDate,
Note.FollowUp
Staff.Surname, Staff...
FROM Staff, Child INNER JOIN [Note] ON Child.ChildID = Note.ChildID;


I guess I could change my stSelCrit to
SELECT ... FROM Note ORDER BY NoteDate DESC;
since I am now only drawing fields from the Note table.

Thanks Krzysztof
 
L

.Len B

| || .Len B wrote:
||| The following is in the OnOpen event of a form. It is designed to
||| populate an ocx control in the form.
|||
||| Dim rst As Recordset, stSelCrit As String
||| stSelCrit = "SELECT NoteDate, LogonName, CNote FROM selqNotes"
||| stSelCrit = stSelCrit & " ORDER BY NoteDate DESC;"
||| Set rst = CurrentDb.OpenRecordset(stSelCrit)
||| The Set rst = statement generates the error:
||| Too few parameters. Expected 1. (3061)
|||
||| It used to work but stopped working after I added a new combo to
||| the form. I can't see how that caused it.
|||
||| It says it is expecting 1 paramater. By my count it is getting
||| one, just one.
||
||
|| What is your selqNotes ?
|| Is it another query, that has references to any form control?
||
|| If so, use querydef object and evqaluate your parameter:
||
|| Dim qr as QueryDef
|| Dim pr as parameter
||
|| set qr = currentDb.CreateQueryDef("", stSelCrit)
|| For each pr in qr.Parameters
|| pr.Value = Eval(pr.Name)
|| Next
||
|| Set rst = qr.OpenRecordset
||
|| ---
|| KN
|
| selqNotes is a select query without parameters.
|
| SELECT Child.ChildID, Child.FamilyNum, Child.Surname,Child...,
| Note.NoteDate, Note.CNote, Note.LogonName, Note.ContactDate,
| Note.FollowUp
| Staff.Surname, Staff...
| FROM Staff, Child INNER JOIN [Note] ON Child.ChildID = Note.ChildID;
|
|
| I guess I could change my stSelCrit to
| SELECT ... FROM Note ORDER BY NoteDate DESC;
| since I am now only drawing fields from the Note table.
|
| Thanks Krzysztof
| --
| Len
| ______________________________________________________
| remove nothing for valid email address.
|

Yep. Changing stSelCrit did the trick!!
 

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