Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
2.1k views
in Technique[技术] by (71.8m points)

vba - Run-time error '3061'. Too few parameters. Expected 1. (Access 2007)

I have the following 'set recordset' line that I cannot get working. The parameters seem correct according to all available help I can find on the subject.

The error displays :

"Run-time error '3061'. Too few parameters. Expected 1."

Here is the line of code:

Set rs = dbs.OpenRecordset("SELECT Centre_X, Centre_Y FROM [qry_all_details] 
WHERE ID = " & siteID & ";", dbOpenSnapshot)

Where rs is the recordset (Dim rs As Recordset) and dbs = CurrentDb()

Any help would be appreciated.

I have tried removing the WHERE cause with no effect, and also using single quotes between double quotes, but no joy.

Many thanks.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

"Run-time error '3061'. Too few parameters. Expected 1."

I believe this happens when the field name(s) in your sql query do not match the table field name(s), i.e. a field name in the query is wrong or perhaps the table is missing the field altogether.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...