Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Run-Time Error 3061

Status
Not open for further replies.

HandJT

Technical User
Jun 23, 2004
84
US
I keep getting a "run-time error 3061 Too few parameteres. Expected 1" when I use the following code.

Set rs3 = dbOpenRecordset ("SELECT * " & _
"FROM Employee_Scrap_Log " & _
"WHERE Employee_Scrap_Log.[NDW#] = '"& me.NDW.Value & '";")

Can anybody tell me what I am doing wrong or why I'm getting this error message?

Thanks in advance.
 
You SHOULD be getting a syntax error, not a run-time error.
The statement you provided has the last apostrophe before the quote-semicolon-quote. That apostrophe would start a VBA comment, which means that the final "&" operator has no second operand. That's a syntax error.

If this was a typo, and the last apostrophe is actually within the quotes, then the only way I can see this error would occur is that the Employee_Scrap_Log table/query has no field named NDW#. Fields in a query that have no corresponding field in the recordset are assumed to be query parameters. When you open such a query from the Database Window, Access prompts for the parameter values, but when you open it in code Access expects the code to set up the parameter values in advance. If the code doesn't do this, error 3061 results.

If that doesn't explain the problem, you must have mistyped the statement some other way. Try again using cut and paste to avoid typos.

Rick Sprague
Want the best answers? See faq181-2886
To write a program from scratch, first create the universe. - Paraphrased from Albert Einstein
 
How have you defined rs3?

Only specific types of variables can be set, such as recordsets.
 
Yes, I defined rs3 and I did type it right, however I used that same statement in the same code and it worked just fine. I'm adding something else to the code and just copied and pasted it, but here it doesn't seem to work. I'll try to figure it out, but thanks for your help.
 
HandJT

Set rs3 = dbOpenRecordset ("SELECT * " & _
"FROM Employee_Scrap_Log " & _
"WHERE Employee_Scrap_Log.[NDW#] = '[COLOR=blye yellow]" &[/color] me.NDW.Value & [COLOR=blue yellow]"');"[/color]

- add a space before the ampersamd, "&"
- is double quote " + single quote ', not the other way
- semi colon, ";" at the end per RickSpr

Lastly, does
me.NDW
...have a value

My guess is on the quote issue since I suspect Access will need to decide what is within and outside the double quotes.

Richard
 
Willir . . . RickSpr . . . .

Here's the Where Clause copied & inserted in code view:
Code:
"WHERE Employee_Scrap_Log.[NDW#] = '"& me.NDW.Value & '";")

As you can see [blue]'";"[/blue] is correct. However [blue]willir[/blue] is correct in pointing out the missing space in [blue]'"&[/blue]

This is certainly an [blue]Optical Illusion[/blue].

Calvin.gif
See Ya! . . . . . .
 
How are ya HandJT . . . . .

Try changing:
[blue] me.NDW.Value[/blue]
To:
[blue] me[purple]![/purple]NDW.Value[/blue]
Or:
[blue] me[purple]![/purple]NDW[/blue]

Calvin.gif
See Ya! . . . . . .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top