Loading...
Friday, April 11, 2014

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

The solution to MS Access run-time error "Run-time error '3061'. Too few parameters. Expected 1."



If you run into MS Access run-time error "Run-time error '3061'. Too few parameters. Expected 1." when you run the query in MS Access,  the cause of this error might be one of the following causes.

1.) You might forget to put the single quote (') around the variable in the where cause in the query.

For example:
If I my table structure is

CREATE TABLE Persons

(

PersonID int,

LastName varchar(255),

FirstName varchar(255),

Address varchar(255),

City varchar(255)

);

The query that yield this error is something like

Set rs = dbs.OpenRecordset("Select * From Persons Where FirstName = " & p_firstname & ";", dbOpenSnapshot)

To solve this problem, bring the hero, which is the single code ('), to help like this:

Set rs = dbs.OpenRecordset("Select * From Persons Where FirstName = '" & p_firstname & "';", dbOpenSnapshot)


2.) The field of the table is missing, or misspelling. You need to check your query and make sure every fields in the query is spelled correctly or exists in the table.

From the table structure above, the query that might yield this error is:

Set rs = dbs.OpenRecordset("Select First_Name, Last_Name From Persons Where PersonID = 3;", dbOpenSnapshot)

To solve this problem, correct the fields in the query like this:

Set rs = dbs.OpenRecordset("Select FirstName, LastName From Persons Where PersonID = 3;", dbOpenSnapshot)

From the 2 examples above, I hope you can solve your "Run-time error '3061'. Too few parameters. Expected 1." run-time error.

0 comments:

Post a Comment

 
TOP