Error 3061

B

Bill

In my OnOpen code (Below), I get a Run-time
error '3061': Too few parameters. Expected 1.
on the "Set rs" statement. (The strSQL string
is correct.) The statement itself was a suggestion
from Allen Browne in response to my post:
"RecordsetClone equivalent for Reports" from
Tuesday, 8/8. (See that thread for details) I
didn't get the chance to ask Allen about the
notation "(0)(0)", (which I don't see anywhere
in 2003 HELP), so I don't know if that has
anything to do with the error or not.

What's the problem?

Bill

==========(Begin Code)============
Private Sub Report_Open(Cancel As Integer)
Dim strTemp() As String
Dim rs As DAO.Recordset
Dim strSQL As String
strTemp = Split(Me.OpenArgs, ";")
strRetDate = strTemp(0)
strPayTo = strTemp(1)
lngSendID = strTemp(2)
strAmt = strTemp(3)
strRecBy = strTemp(4)
strRegards = strTemp(5)


strSQL = "SELECT * FROM QAsilomar WHERE RegistryID = " & lngSendID & ";"
Set rs = DBEngine(0)(0).OpenRecordset(strSQL) <<<<<<<<<ERROR HERE
With rs
If .RecordCount > 0 Then
strFname = Nz(!FIRSTNAME, vbNullString)
strLname = Nz(!LASTNAME, vbNullString)
strAdr = Nz(![ADDRESS], vbNullString)
strCS = Nz(![CITYSTATE], vbNullString)
strZip = Nz(![ZIP], vbNullString)
strHomeNo = Nz(![HOMEPHONE], vbNullString)
strWorkNo = Nz(![WORKPHONE], vbNullString)
strCellNo = Nz(![CELLPHONE], vbNullString)
End If
End With
rs.Close
Set rs = Nothing

End Sub
==============(End Code)=================
 
J

jmonty

Try adding:

Dim db as database

then...

Set db = CurrentDb()
Set rs = db.Openrecordset(strSQL)

and at the end (AFTER the set rs= nothing statement...) add:

set db = nothing

jmonty
 
D

Douglas J. Steele

If that doesn't solve the problem, make sure you didn't mistype RegistryID.
As well, if RegistryID is a text field, you'll need quotes around the value:

strSQL = "SELECT * FROM QAsilomar WHERE RegistryID = '" & lngSendID & "'"

Exagerated for clarity, that's

strSQL = "SELECT * FROM QAsilomar WHERE RegistryID = ' " & lngSendID & " ' "

(the terminating semicolon isn't mandatory)

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


jmonty said:
Try adding:

Dim db as database

then...

Set db = CurrentDb()
Set rs = db.Openrecordset(strSQL)

and at the end (AFTER the set rs= nothing statement...) add:

set db = nothing

jmonty


Bill said:
In my OnOpen code (Below), I get a Run-time
error '3061': Too few parameters. Expected 1.
on the "Set rs" statement. (The strSQL string
is correct.) The statement itself was a suggestion
from Allen Browne in response to my post:
"RecordsetClone equivalent for Reports" from
Tuesday, 8/8. (See that thread for details) I
didn't get the chance to ask Allen about the
notation "(0)(0)", (which I don't see anywhere
in 2003 HELP), so I don't know if that has
anything to do with the error or not.

What's the problem?

Bill

==========(Begin Code)============
Private Sub Report_Open(Cancel As Integer)
Dim strTemp() As String
Dim rs As DAO.Recordset
Dim strSQL As String
strTemp = Split(Me.OpenArgs, ";")
strRetDate = strTemp(0)
strPayTo = strTemp(1)
lngSendID = strTemp(2)
strAmt = strTemp(3)
strRecBy = strTemp(4)
strRegards = strTemp(5)


strSQL = "SELECT * FROM QAsilomar WHERE RegistryID = " & lngSendID & ";"
Set rs = DBEngine(0)(0).OpenRecordset(strSQL) <<<<<<<<<ERROR HERE
With rs
If .RecordCount > 0 Then
strFname = Nz(!FIRSTNAME, vbNullString)
strLname = Nz(!LASTNAME, vbNullString)
strAdr = Nz(![ADDRESS], vbNullString)
strCS = Nz(![CITYSTATE], vbNullString)
strZip = Nz(![ZIP], vbNullString)
strHomeNo = Nz(![HOMEPHONE], vbNullString)
strWorkNo = Nz(![WORKPHONE], vbNullString)
strCellNo = Nz(![CELLPHONE], vbNullString)
End If
End With
rs.Close
Set rs = Nothing

End Sub
==============(End Code)=================
 
B

Bill

The whole problem was the field name. Had Doug not cautioned
the data type of RegistryID and lngSendID, I might not have spotted
the "real" error...... the pitfalls of copying code from another module.
Anyway, the field name should have been "RecordID", which is
the keyed autonumber field for the recordset.

Thanks for the "wakeup" Doug.... and your thoughts as well jmonty.
Bill




Douglas J. Steele said:
If that doesn't solve the problem, make sure you didn't mistype
RegistryID. As well, if RegistryID is a text field, you'll need quotes
around the value:

strSQL = "SELECT * FROM QAsilomar WHERE RegistryID = '" & lngSendID & "'"

Exagerated for clarity, that's

strSQL = "SELECT * FROM QAsilomar WHERE RegistryID = ' " & lngSendID & " '
"

(the terminating semicolon isn't mandatory)

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


jmonty said:
Try adding:

Dim db as database

then...

Set db = CurrentDb()
Set rs = db.Openrecordset(strSQL)

and at the end (AFTER the set rs= nothing statement...) add:

set db = nothing

jmonty


Bill said:
In my OnOpen code (Below), I get a Run-time
error '3061': Too few parameters. Expected 1.
on the "Set rs" statement. (The strSQL string
is correct.) The statement itself was a suggestion
from Allen Browne in response to my post:
"RecordsetClone equivalent for Reports" from
Tuesday, 8/8. (See that thread for details) I
didn't get the chance to ask Allen about the
notation "(0)(0)", (which I don't see anywhere
in 2003 HELP), so I don't know if that has
anything to do with the error or not.

What's the problem?

Bill

==========(Begin Code)============
Private Sub Report_Open(Cancel As Integer)
Dim strTemp() As String
Dim rs As DAO.Recordset
Dim strSQL As String
strTemp = Split(Me.OpenArgs, ";")
strRetDate = strTemp(0)
strPayTo = strTemp(1)
lngSendID = strTemp(2)
strAmt = strTemp(3)
strRecBy = strTemp(4)
strRegards = strTemp(5)


strSQL = "SELECT * FROM QAsilomar WHERE RegistryID = " & lngSendID & ";"
Set rs = DBEngine(0)(0).OpenRecordset(strSQL) <<<<<<<<<ERROR HERE
With rs
If .RecordCount > 0 Then
strFname = Nz(!FIRSTNAME, vbNullString)
strLname = Nz(!LASTNAME, vbNullString)
strAdr = Nz(![ADDRESS], vbNullString)
strCS = Nz(![CITYSTATE], vbNullString)
strZip = Nz(![ZIP], vbNullString)
strHomeNo = Nz(![HOMEPHONE], vbNullString)
strWorkNo = Nz(![WORKPHONE], vbNullString)
strCellNo = Nz(![CELLPHONE], vbNullString)
End If
End With
rs.Close
Set rs = Nothing

End Sub
==============(End Code)=================
 

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