• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 434
  • Last Modified:

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

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

1 Solution
Guy Hengel [angelIII / a3]Billing EngineerCommented:
your query CANNOT work.
you only have:
FROM qryLMSummary

while your SELECT shows 3 different tables to be retrieve the columns from ...
To be honest I am not sure, but this page looks lke it may be of some use:
Have a look for error 3061 in the following article:

Rey Obrero (Capricorn1)Commented:
are the three tables the source of query qryLMSummary?

try this

sSQL = "SELECT TOP 1 ChannelText, FlowText, FreightPaymentText FROM qryLMSummary"
ltdanp22Author Commented:
Whoops, just forgot I made some changes. Thanks!!!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get 10% Off Your First Squarespace Website

Ready to showcase your work, publish content or promote your business online? With Squarespace’s award-winning templates and 24/7 customer service, getting started is simple. Head to Squarespace.com and use offer code ‘EXPERTS’ to get 10% off your first purchase.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now