Run-time error '3061': Too Few Parameters.

Posted on 2010-01-07
Last Modified: 2013-11-28
The code below breaks at dbs.OpenRecordset with the error Run-time error '3061': Too few parameters. Expected 3.

When I type the SQL string into a query designer in Access, the results come back and are correct. Any idea what's wrong with the code? Thanks!

Private Sub OptimalBucket()

    Dim dbs As Database

    Dim rst As Recordset

    Dim sSQL As String


    sSQL = "SELECT TOP 1 valChanType.ChannelText, valFlow.FlowText, valFreightPayment.FreightPaymentText FROM qryLMSummary"


    Set dbs = CurrentDb

    Set rst = dbs.OpenRecordset(sSQL) <-- Breaks here!


    With rst

        txtChanType.Value = .Fields("ChannelText")

        txtFreightPayment.Value = .Fields("FreightPaymentText")

        'txtSourcing.Value = .Fields("SourcingText")

        txtFlow.Value = .Fields("FlowText")


    End With

    Set rst = Nothing

End Sub

Open in new window

Question by:ltdanp22
    LVL 142

    Accepted Solution

    your query CANNOT work.
    you only have:
    FROM qryLMSummary

    while your SELECT shows 3 different tables to be retrieve the columns from ...
    LVL 3

    Expert Comment

    To be honest I am not sure, but this page looks lke it may be of some use:
    LVL 46

    Expert Comment

    Have a look for error 3061 in the following article:

    LVL 119

    Expert Comment

    by:Rey Obrero
    are the three tables the source of query qryLMSummary?

    try this

    sSQL = "SELECT TOP 1 ChannelText, FlowText, FreightPaymentText FROM qryLMSummary"

    Author Closing Comment

    Whoops, just forgot I made some changes. Thanks!!!

    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    Join & Write a Comment

    Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
    If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
    What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
    This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    24 Experts available now in Live!

    Get 1:1 Help Now