Error 3061

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have the following codes. When I run it. it shows Error 3061, too few
parameters, expect 1. on Set rs = db.OpenRecordset(strSQL)
Please help out!

Dim db As DAO.Database, rs As DAO.Recordset
Dim strSQL As String

strSQL = "Select EMAIL From AGENT where COUNTY =" &
[Forms]![frmReport]![listCounty]

Set db = CurrentDb

Set rs = db.OpenRecordset(strSQL)

strAccount = rs!
Do While Not rs.EOF
rs.AddNew
strAccount = strAccount & ",rs![EMAIL]"
rs.Update

rs.MoveNext
Loop
rs.Close

Set rs = Nothing
Debug.Print strAccount
 
Hi, Lily.

Make sure that the field names EMAIL and COUNTY are spelled correctly, and
the table AGENT is spelled correctly. Also, if COUNTY is not a numerical
value, then the value assigned in the WHERE clause needs to have the string
delineators surrounding the string value, such as single quotes. If COUNTY
is a Text field, then try the following:

strSQL = "Select EMAIL From AGENT where COUNTY = '" & _
[Forms]![frmReport]![listCounty] & "';"

And make sure that there is a value to assign to the WHERE clause in the
listCounty control on the frmReport form. If it's empty or the form isn't
open when this query runs, you'll have problems with the query.

HTH.

Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address, so that a message
will be forwarded to me.)

- - -
When you see correct answers to your question posted in Microsoft's Online
Community, please sign in to the Community and mark these posts, so that all
may benefit by filtering on "Answered questions" and quickly finding the
right answers to similar questions. Remember that the best answers are often
given to those who have a history of rewarding the contributors who have
taken the time to answer questions correctly.
 
Back
Top