By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,515 Members | 1,339 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,515 IT Pros & Developers. It's quick & easy.

to few parameters error working with recordset

P: n/a
Hear is the part of code:

Dim db As DAO.Database
Dim rst As DAO.Recordset
Set db = CurrentDb()
Set rst = db.OpenRecordset("SELECT FirstName FROM People
WHERE LastName = " & LastName
& "")

Select statement is correct but it still promts me error message "To
few parameters expected 1"
Is it the problem with local variable &LastName& ?I'm quite confused.

Aug 20 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
If LastName is a Text field (not a Number field), you need extra quotes:

"SELECT FirstName FROM People WHERE LastName = """ & LastName & """"

More info:
http://allenbrowne.com/casu-17.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"MirzaSila" <mi*******@gmail.comwrote in message
news:11*********************@h48g2000cwc.googlegro ups.com...
Hear is the part of code:

Dim db As DAO.Database
Dim rst As DAO.Recordset
Set db = CurrentDb()
Set rst = db.OpenRecordset("SELECT FirstName FROM People
WHERE LastName = " & LastName
& "")

Select statement is correct but it still promts me error message "To
few parameters expected 1"
Is it the problem with local variable &LastName& ?I'm quite confused.

Aug 20 '06 #2

P: n/a
Thanks a Lot
Problem solved!
Allen Browne wrote:
If LastName is a Text field (not a Number field), you need extra quotes:

"SELECT FirstName FROM People WHERE LastName = """ & LastName & """"

More info:
http://allenbrowne.com/casu-17.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"MirzaSila" <mi*******@gmail.comwrote in message
news:11*********************@h48g2000cwc.googlegro ups.com...
Hear is the part of code:

Dim db As DAO.Database
Dim rst As DAO.Recordset
Set db = CurrentDb()
Set rst = db.OpenRecordset("SELECT FirstName FROM People
WHERE LastName = " & LastName
& "")

Select statement is correct but it still promts me error message "To
few parameters expected 1"
Is it the problem with local variable &LastName& ?I'm quite confused.
Aug 20 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.