Too few parameters?!?

Can anyone check this code and tell me where i've gone wrong....please!

VBA code is:

Private Sub ConfirmBooking_Click()
Dim DB As DAO.Database
Dim rst As DAO.Recordset

Set DB = CurrentDb()
Set rst = DB.OpenRecordset("qryBooking")

If rst.BOF And rst.EOF Then
Call MsgBox("Your booking is confirmed", vbExclamation, "Booking Confirmed")
DoCmd.GoToRecord , , acNewRec
Do Until rst.EOF
If rst.RecordCount > 0 Then
Call MsgBox("Sorry this aircraft is already booked, please choose another time", vbCritical, "Error")
End If
End If
End Sub

and the SQL query code is:

SELECT BookingDetails.AcReg, BookingDetails.HireDate, BookingDetails.StartTime, BookingDetails.EndTime,
FROM BookingDetails
WHERE (((BookingDetails.AcReg)=Forms!BookingForm!cboAcRe g)
((BookingDetails.HireDate)=Forms!BookingForm!cboHi reDate)
((BookingDetails.StartTime) Between forms!bookingform!cboStarttime And Forms!BookingForm!cboEndTime)
Or (((BookingDetails.AcReg)=Forms!BookingForm!cboAcRe g)
And ((BookingDetails.HireDate)=Forms!BookingForm!cboHi reDate)
And ((BookingDetails.EndTime) Between forms!bookingform!cboStarttime And Forms!BookingForm!cboEndTime) ;
the error message i get is runtime error 3061, too few parameters: expected 4

i can't figure out why

this code runs from a button on my form which contains all the above fields as combo boxes!

Any pointers anyone?


Post your answer or comment

comments powered by Disqus
I have a report that when opened by a command button code works fine, but when I try using a macro to run it the following error message appears:

Run-time error ‘3061’. Too few parameters. Expected 1.

The reason I wish to use a macro is I wanted to display a message box that said “No Records to View” if the report would not display anything. I use the same macro ‘code’ in other instances and there’s not a problem.

The macro uses the following function in a separate module. (The line Set r = db.OpenRecord … is highlighted when I debug the error message).

Function getCount(strRs As String)

Dim r As Recordset
Dim db As Database

Set db = CurrentDb
Set r = db.OpenRecordset(strRs)

getCount = r.RecordCount


End Function

I can supply more info about the macro if necessary – it was just difficult to know how to lay it all out! Hope this all makes sense!

Good Afternoon!
Does anyone see anything wrong with this query? I am getting an error "Too few Parameters, Expected 1"

I have been working on this for the last 2 hours trying to figure it out!!

Pbaldy had helped me with another piece of this. Basically I have a subform with all of the below fields.
Once the user clicks on the "Amount" field, these records are sent to unbound text boxes for updating. Once the user is finished updating these fields they hit a subit button which is supposed to run the update query below.

PHP Code:
Private Sub Command96_Click()
Dim db As DAO.Database
Set db = CurrentDb
sqlupdate = "UPDATE Main_PIP_TBL SET Main_PIP_TBL.Account = '" & Me.PIP_Account & "', "
sqlupdate = sqlupdate & "Main_PIP_TBL.Amount = '" & Me.Amount_PIP_Update & "', "
sqlupdate = sqlupdate & "Main_PIP_TBL.PPM_Code = '" & Me.PPM_Code_PIP_Update & "', "
sqlupdate = sqlupdate & "Main_PIP_TBL.Pay_Date = '" & Me.Pay_Date_PIP_Update & "', "
sqlupdate = sqlupdate & "Main_PIP_TBL.Pay_Month = '" & Me.Pay_Month_PIP_Update & "', "
sqlupdate = sqlupdate & "Main_PIP_TBL.Starts_On = '" & Me.Starts_On_PIP_Update & "', "
sqlupdate = sqlupdate & "Main_PIP_TBL.Ends_On = '" & Me.Ends_On_PIP_Update & "', "
sqlupdate = sqlupdate & "Main_PIP_TBL.Funding = '" & Me.Funding_PIP_Update & "', "
sqlupdate = sqlupdate & "Main_PIP_TBL.Update_Date = Now(), "
sqlupdate = sqlupdate & "Main_PIP_TBL.Associate_Name = fosusername "
sqlupdate = sqlupdate & "WHERE Main_PIP_TBL.AutoNBR = '" & Me.AutoNBR_PIP_Update & "';"
db.Execute (sqlupdate)
MsgBox "done" 

Hi all,

Having an issue with runtime error 3061 when creating SQL in VBA. I've run
into this previously, where I need to pass parameters to my queries through
VBA and have overcome it in the past by recreating the SQL in VBA itself, so
that I can say "this is the value you want" and then use db.Execute to run
the query.

The problem is, now I need to run a nested query. The query itself doesn't
actually have any specific parameters, they're in the 3 nested ones. It's
only 1 parameter, shared by the 3 queries to make sure they're all loading
the same review.

What I'm trying to do is update values in the first nested query to match
values in the other 2. But only where the values in query 2 are equal (agreed)
to the values in query 3. This will leave all unmatched values as null.

So in short hand... Update query1, inner join query1, query2, query3. Update
query1 value to query3, where query2 value = query3 value.

When I execute the sql though, it advises me (to be fair, I expected it would
do so) that there are too few parameters. Expected 1.

Thanks for your time and assistance!


Code pasted below (apologies for the mess, I'm still learning some of this):

Parent query:

	strsql = "UPDATE ([qry_AgreedRatingFilter] INNER JOIN
[qry_AgreedRating_SubSelf] ON ([qry_AgreedRatingFilter].[txt_CapabilityLink]
= [qry_AgreedRating_SubSelf].[txt_CapabilityLink]) AND (
[qry_AgreedRatingFilter].[txt_CapabilityGroupLink] =
[qry_AgreedRating_SubSelf].[txt_CapabilityGroupLink])) INNER JOIN
[qry_AgreedRating_SubMgr] ON ([qry_AgreedRating_SubSelf].[txt_CapabilityLink]
= [qry_AgreedRating_SubMgr].[txt_CapabilityLink]) AND (
[qry_AgreedRating_SubSelf].[txt_CapabilityGroupLink] =
[qry_AgreedRating_SubMgr].[txt_CapabilityGroupLink]) SET
[qry_AgreedRatingFilter].[txt_RatedLevel] = [qry_AgreedRating_SubMgr].
[txt_RatedLevel] WHERE ((([qry_AgreedRating_SubSelf].[txt_RatedLevel]) =

Nested Queries: These are all the same query, but with the explicitly set
parameter changed for each one. There are 3 possible values: "Agreed" (AgreedRatingFilter)
"Manager" (AgreedRating_SubMgr) and "Self" (AgreedRating_SubSelf), which I've tried to show below.

	SELECT tbl_CapReview.id_Review, tbl_CapSequence.id_CapSequence,
tbl_CapSequence.txt_SequenceType, tbl_Capability.txt_CapabilityGroupLink,
tbl_CapabilityListing.txt_CapabilityLink, tbl_CapRatings.txt_RatedLevel
FROM ((tbl_User INNER JOIN tbl_CapReview ON tbl_User.id_User = tbl_CapReview.
txt_ReviewUser) INNER JOIN tbl_CapSequence ON tbl_CapReview.id_Review =
tbl_CapSequence.txt_ReviewID) INNER JOIN (tbl_Capability INNER JOIN
(tbl_CapabilityListing INNER JOIN tbl_CapRatings ON tbl_CapabilityListing.
id_CapabilityListing = tbl_CapRatings.txt_RatingCapability) ON tbl_Capability.
id_Capability = tbl_CapabilityListing.txt_CapabilityLink) ON tbl_CapSequence.
id_CapSequence = tbl_CapRatings.txt_RatingReview
WHERE (((tbl_CapReview.id_Review)=[Forms]![frm_Dynamic]![sub_Detail].[Form]!
[ReviewFilter]) AND ((tbl_CapSequence.txt_SequenceType)


I am trying to bulid an sql query in VBA. But I get a missing Operand error or too few parameters expected 1 error.

My code is

sqltxt = "Select * from Overallquery " & _
" WHERE ([Region] =" & Chr$(34) & Me.Region.Value & Chr$(34) & _
" OR [SBU] =" & Chr$(34) & Me.SBU.Value & Chr$(34) & _
" OR [Officer Name] =" & Chr$(34) & Me.OfficerName.Value & Chr$(34) & _
")and [Product] =" & Chr$(50) & Me.Product.Value & Chr$(50)

The debug screen shows that

there are " qoutes in front of Region, SBU and Officer Name but in front
of product 2 is added like it will be
[Product] =2Commfix2

If I comment the product line the code works properly.
I dont understand what is different that it is not working.
Really need help on this big time.
Thanks in Advance,

Hello All,
I am trying to run this code:

Dim strIn As String
Dim rst As DAO.Recordset
Dim strSQL As String

Set rst = Me.RecordsetClone

Do Until rst.EOF
strIn = strIn & rst!ChildHSReferenceNumber & ","

If Right(strIn, 1) = "," Then
strIn = Left(strIn, Len(strIn) - 1)
End If

strSQL = "Update HSChild Set HSChildOver6Month = 'Yes' "
strSQL = strSQL & "WHERE ChildHSReferenceNumber IN(" & strIn & ")"

CurrentDb.Execute strSQL

Set rst = Nothing

but I keep getting an error messages: too few parameters? what can be going wrong? many thanks for your helps...

SOS. Please help!

i have a very simple thing that i'm trying to do.

Dim rs As DAO.Recordset

Set rs = CurrentDb.OpenRecordset("SELECT Count(*) FROM Flights where Flights.Plane_ID.Value = '" & Me!Plane_ID.Value & "'")

Set rs = Nothing

but i'm getting the error: run time error 3061. Too few parameters. Expected 1

what can i do?

I am trying to use the following code:

Set rst = dbs.OpenRecordset("qryCreateForm")

My intent is to create a form. The query qryCreateForm is the record source for the form. I am getting a compile error "Too few parameters. Expecting 1."

Any idea what I am missing?


Hello All,

I have a questions. This code was working fine but, when I added more data to the table it would error "saying overflow" so I changed

Dim pID As Interger to
Dim pID as Long

Now it is saying "Too few parameters. Expected 1. Its has an error on the line that says "dbs.Execute cmd, dbSeeChanges"

Not sure what this means.
Here is the code.

	Private Sub Form_AfterUpdate()
Dim dd As Date
    Dim dbs As DAO.Database
    Set dbs = CurrentDb
    Dim pID As Long
    Dim sHostName As String
    Dim sUserName As String
    Dim cmd As String
    pID = [product id].Value 
    dd = Format(Now(), "dd/mm/yyyy hh:mm:ss")
    ' Get Host Name / Get Computer Name
    sHostName = Environ("computername")
    ' Get Current User Name
    sUserName = Environ("username")        'Username is obtained to produce Time and UserStamp
    cmd = "UPDATE Product SET DateStamp=#" & dd & "#, UserStamp='" & sUserName & "' WHERE [productID]=" & pID & ""
    dbs.Execute cmd, dbSeeChanges
End Sub

Any Ideas??


I am exporting a record set to Excel within a loop and I am encountering the following error while defining that record set:

Error 3061 - Too few parameters - Expected 1

The line of code highlighted is:

	Set SResults = db.OpenRecordset(sqlResult)

The line in context is:

	For x = 1 To n
    sqlResult = "SELECT [Annual Material Cost], [Total Logistics Cost], [Logistics Cost per Part], [Total Annual Cost per
Part] FROM TACFinal_tbl WHERE [TAC ID] =  '" & Me.TACID_tbx & "' AND [Scenario ID] = " & x
    Set SResults = db.OpenRecordset(sqlResult)
    objSht.Cells(4, y).CopyFromRecordset SResults
    y = y + 4

Please help as I am stuck on this for a long time!

Thanks in advance

I’m doing some work on my day off and I’m having some problems with transferring data from one form to another. Currently I am getting a run-time 3061 error ‘too few parameters. Expected 1.’

I’ve had the help from mr boblarson prior in the development of this code and looking to take it a step futher.

The first form that displays the data is called ‘ReviewPurchaseOrder’ and has a command button that opens another form with the following code:

	Option Compare Database
Private Sub btnDHS_Click()
 Dim stDocName As String
        stDocName = "DHS1501"
        DoCmd.OpenForm stDocName
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim i As Integer
Set db = CurrentDb
Set rst = db.OpenRecordset("SELECT * FROM tblPurchaseOrderDetails WHERE RequisitionID=" & RequisitionID)
i = 1
If rst.RecordCount > 0 Then
   Do Until rst.EOF
     Forms!DHS1501.Controls(i & "txtItem1") = rst("ItemDescription")
     Forms!DHS1501.Controls(i & "txtItem2") = rst("StockNum")
     Forms!DHS1501.Controls(i & "txtItem3") = rst("Quantity")
     Forms!DHS1501.Controls(i & "txtItem4") = rst("UnitofIssue")
     Forms!DHS1501.Controls(i & "txtItem5") = rst("UnitPrice")
     Forms!DHS1501.Controls(i & "txtItem6") = rst("Quantity") * rst("UnitPrice")
    i = i + 1
End If
Set rst = Nothing
End Sub

I then get the above error message. I am trying to take the current record of the ‘ReviewPurchaseOrder’ form and move to a new custom form to display the data. This form has linked criteria from what the user selects on the previous form. Currently the form pulls ALL the data from the table, not just the current record. The form also displays an error after 11 entries have been made because the ‘Do Until rst.EOF’ continues past my 10th ItemDescription.

Anyone have any suggestions on what I could do or where I could read?

Thank you.

Hi All

In a module I need to open a dataset that includes 2 subqueries. I created the main query - with the 2 subqueries - using the querybuilder, and this all ran perfectly, so I then went to sql view to get the sql, and pasted this into the OpenRecordset statement. The initial query had one field ([practice]) that needed a parameter from the current form, and I knew I had to replace the reference to the current form with a variable from the sub - so:

[Forms]![frm x main]![prac name]
'" & strPractice & "'
(strPractice is also used elsewhere in the sub)

Having done that, I'm still getting the "Too Few Parameters..." error

The complete OpenRecordset statement is:

	    Set rsStaffNormals = CurrentDb.OpenRecordset("SELECT [qry x all staff].practice, [qry x all staff].staff_name, " & _
    "(SELECT sum([amount]) from [qry x main table next mth] " & _
    "where [qry x main table next mth].[staff_name]=[qry x all staff].staff_name) " & _
    "AS TotalAmount, " & _
    "(SELECT sum([qry x main table next mth].[stafpay].[Tnumber]) " & _
    "from [qry x main table next mth] " & _
    "where [qry x main table next mth].[staff_name]=[qry x all staff].staff_name) " & _
    "AS TotalNumber, [qry x all staff].hasLEFT " & _
    "from [qry x all staff] " & _
    "WHERE [qry x all staff].practice= '" & strPractice & "' " & _
    "AND [qry x all staff].hasLEFT=False;")

Can anyone see what's up with this
Grateful for any help.


I have a function I built that takes in values from a form. I am trying to add an additional sql statement to it so that I can have two separate record sets. The mainsql is the main recordset that I want the strSql recordset to be able to take from. I keep getting a Run Time Error Too few parameters expected. Expected 4, Run-time error '3061'. I can't figure out what other parameters it is looking for. I have confirmed that all of the parameters that I pass in are being passed in when I stepped through.

I bolded the section I get the error on.

Thank you in advance.

Dim rs As Recordset
Dim strSQL As String
Dim n As Long
Dim sglHold As Long
Dim mainrs As Recordset
Dim mainsql As String
Dim ntotal As Integer

mainsql = "SELECT tble_TempLOSDate.Facility, tble_TempLOSDate.[Pt Acct Nbr], tble_TempLOSDate.Dispositions, tble_TempLOSDate.TL, tble_TempLOSDate.[AdmitDate&Time], tble_TempLOSDate.[DischargeDate&Time], tble_TempLOSDate.LOS, tble_TempLOSDate.DispID, tble_TempLOSDate.FacilityID " & _
"FROM tble_TempLOSDate " & _
"WHERE (((tble_TempLOSDate.[AdmitDate&Time]) Between [pStartDate] And [pEndDate]) AND ((tble_TempLOSDate.DispID)=pDisposition) AND ((tble_TempLOSDate.FacilityID)=pFacility));"

Set mainrs = CurrentDb.OpenRecordset(mainsql)
ntotal = mainrs.RecordCount

strSQL = "SELECT " & LOS & " from " & mainsql & " WHERE " & LOS & ">=0 Order by " & LOS & ";"
Set rs = CurrentDb.OpenRecordset(strSQL)
n = rs.RecordCount
rs.Move -Int(n / 2)

If n Mod 2 = 1 Then 'odd number of elements
MedianAutoF = rs(pfield)
Else 'even number of elements
sglHold = rs(pfield)
sglHold = sglHold + rs(pfield)
MedianAutoF = sglHold / 2
End If
End Function

I have the following SQL code which gives me run time error 3061 - Too few parameters, expected 1. Any ideas what I'm doing wrong? If I place a value like #01/11/12# in place of Me.Calendar9.Value then it works OK.

	strSQL = "UPDATE tblAppealCases SET tblAppealCases.[ModRequestSMEAdjudicationDeadline] = DateAdd('d',14,Me.Calendar9.Value)
WHERE (((tblAppealCases.[LetterReference])=" & strLetterReference & "));"

I have a form, which is opened from another form. When I try doing anything on the second form, I get the error message:

Run-time error ‘3061’:

Too few parameters. Expected 2

The code that is running is:

	Private Sub ACPDailyDate_Exit(Cancel As Integer)
    Dim x, y, z As String
    Dim r As Recordset, db As Database
    Dim DocName As String
    Dim LinkCriteria As String
    DocName = "frmACPData"
    Dim intNewRecord As Integer
    intNewRecord = IsNull(Me.ACPDailyID)
    Set db = CurrentDb()
    Set r = db.OpenRecordset("qryPtACPDaily")

    'If intNewRecord Then
        Do Until r.EOF
            If r.Fields("acpdailydate") = Me.ACPDailyDate.Value Then
            msgbox r.Fields("PtFirstName") & " " & r.Fields
("PtLastName") & " already has ACP data for this date " & _
            Chr(13) & r.Fields("acpdailydate"), vbOKOnly + 
vbExclamation, "Warning"
            Exit Sub
            ElseIf r.NoMatch Then
          End If
        Exit Sub
    'End If
        Exit Sub
End Sub

The line highlighted is: Set r = db.OpenRecordset("qryPtACPDaily")

In the query there are 2 parameters:

The query runs fine on its own (when the form’s open).

Does anyone know what’s wrong please?

Hi. I am trying to export a query I stored as a String in VBA (SQLstr) into Excel. However, it gives me the following error:

Could not create spreadsheet.
Error: 3061
Desc: Too few parameters. Expected 2.

The code I am using is as follows (with unimportant stuff left out):

Dim db As Database
Dim rs As Recordset
Dim xl As Object
Dim objWkb, objSht As Variant
Dim SQLstr As String

SQLstr = "SELECT [bunch of stuff] FROM [tablename] WHERE Date Between #1/1/01# AND #1/1/03# ORDER BY Date DESC"

Set db = CurrentDb
Set rs = db.OpenRecordset(SQLstr)
Set xl = CreateObject("Excel.Application")

If rs.RecordCount > 0 Then
With xl
Set objWkb = .Workbooks.Add
Set objSht = objWkb.Worksheets(1)

With objSht
.Cells(2, 1).CopyFromRecordset rs
End With
End With
End If

After inserting some Msgboxes to isolate where the error is occurring, I found that it is happening when I try to do the "Set rs" line of code.

Any help with this would be greatly appreciated.

~Seth Neustein

Here's the code:

dim db as database
dim rst as recordset

set db = currentdb()
set rst = db.openrecordset("qryGroup")

It bombs out on the set rst statement with a 'too few parameters' error message. As I've played with it, if I put a query name in that has records in it, I don't get the error. However, any query in my db that has no records results in this error. Since I want to error trap an empty record set, I need to be able to follow the rst with a decision loop dependant upon whether or not the recordset is empty. My Access bible gives me sample code, but I can't get past setting the record set. Any ideas? I looked through other posts and saw one where someone was using an SQL string and got the same error message, but I know I haven't misspelled a field b/c I'm using a query that runs. It's just that sometimes it has data and sometimes not.



I am having the following problem with my code. When it gets to the bit highlighted in red, it gives the following message.
Too few parameters, Expected 20

	Private Sub create_journal1C() ' journal1 - free pupil meals
Dim Count As Integer, client_school_cc As String, meal_price As Double
Dim post_year As String
line_no = 1
Count = 0
batch_no = 0        'journal header details
journal_no = "J1C"
j_date = Now
post_year = IIf(Month(Get_Date) < 4, Right(year(Get_Date) - 1, 2), Format(Get_Date, "yy"))
Call journal_header(batch_no, journal_no, j_date, post_year)

Dim dbs As DAO.Database, rst As DAO.Recordset, intI As Integer
Dim strNumber As String, strBookmark As String
Dim TableSize As Integer, I As Integer, CountList As Integer, match As Boolean
Dim CodeList() As String
Dim rstOrders As DAO.Recordset
Dim lngTotal As Long, no_free_meals As Long, mealtype As String
Dim rstQuery As DAO.Recordset
Dim Select_Query As String
Dim cnn As New ADODB.Connection
Set cnn = CurrentProject.Connection
Set dbs = CurrentDb
'rst.Open "tbdiningcentre", cnn, adOpenDynamic, adLockPessimistic
Set rst = dbs.OpenRecordset("tbdiningcentre") ' Return Database variable pointing to current database.
TableSize = rst.RecordCount
'''''loop through for each dining centre in table
' problem is, don't want to write two lines where the cost code are the same, so need to keep
' a track of what cost codes have been processed, and check each new one against list
ReDim CodeList(TableSize)

Do While Not rst.EOF
    For I = 1 To CountList
        If CodeList(I) = rst("COST-CENTRE") And I  1 Then 'match found
            match = True
            Exit For
        Else: match = False
        End If
    Next I
    CountList = CountList + 1
    CodeList(CountList) = rst("COST-CENTRE")
    Call glrstatus("Processing Cost Centre " & rst("COST-CENTRE"), "Please Wait")
    If IsNull(rst("CLIENT_SCHOOL_MEALS-CC")) Or match = True Then
        client_school_cc = rst("CLIENT_SCHOOL_MEALS-CC")
        '''''''get number of price bandings for journal lines'''''''''''''
        Set rstOrders = dbs.OpenRecordset("tbmealprice")
        Do While Not rstOrders.EOF
            mealtype = rstOrders("MEAL-TYPE-CODE")
            meal_price = rstOrders("MEAL-SERVICE-PRICE")
FROM qrymealsales WHERE MEAL-TYPE-CODE = '" & mealtype & "' AND MEAL-SERVICE-PRICE = " & meal_price & " AND
CLIENT_SCHOOL_MEALS-CC = '" & client_school_cc & "' AND MEAL-TYPE-NAME Like '*PUPIL FREE*' AND week-ending-date= #" &
COST-CENTRE, JournalDate"
Set rstQuery = dbs.OpenRecordset(Select_Query)
            If rstQuery.EOF = True And rstQuery.BOF = True Then
                'no records have been selected
                no_free_meals = 0
                Do While Not rstQuery.EOF
                    no_free_meals = no_free_meals + rstQuery("WEEK-ACTUAL-NO")
                If no_free_meals = 0 Then   'if no sales, skip to next
                    'do nowt
                Else    'journal CREDIT line details
                    batch_no = 0
                    journal_no = "J1C"
                    line_number = line_no
                    ref_number = "w/e " & Format(Journal_Date, "ddmmyy") 'week ending date to which data refers
                    ledger_code = client_school_cc & "/6965"
                    debit_amount = 0        'leave blank- this is a credit journal
                    credit_amount = Format(no_free_meals * meal_price, "####0.00")
                    analysis = no_free_meals & " meals"  'actual no. of free pupil school meals per price banding
                    user_data = 0
                    narrative = "£" & Format(meal_price, "####0.000") & " price " & LCase(Me![DINING-CENTRE-NAME]) 'price of
meal & school name
                    original_account = mealtype
                    debit_units = " "
                    unit_of_measure = " "
                    line_no = line_no + 1
                End If
            End If
    End If
End Sub

Hello to all you Access Experts, i'm having a little problem with some code that i'm trying to modify.
There's something wrong with the following code that i can't figure out.

    Dim dbs As Database
    Dim rst As Recordset
    Dim strSQL As String
    strSQL = "SELECT Description FROM Pk_item WHERE PartNumber = " & ToolingPartNumber.Text & ";"
    Set dbs = CurrentDb()
    Set rst = dbs.OpenRecordset(strSQL, dbOpenDynaset)
    Me.PartDescription.Enabled = True
    Me.PartDescription.Text = rst!Description

I've checked all the table and field names, and they are all correct, i've also made sure i've got all the correct references ticked.

The code falls over at

	Set rst = dbs.OpenRecordset(strSQL, dbOpenDynaset)

With the error "Too few parameters. Expected 1"

I'm sure there's a very simple solution.

Thanks for your help.


After pressing Command Button CmdResearch, after making selections from 7 combo boxes, I receive a error message: Too Few Parameters; Expected 7

Private Sub CmdResearch_Click()
On Error GoTo Err_CmdResearch_Click

'This command button is on frmPriceResearch. After a user makes selections_
'from 7 combo boxes that serve as parameters in the query, QPriceLookup,_
'the user then presses this command button.
'At this point, I am only trying to verify the number of records that made it into the_
'recordset. Later, I'll write code to "do something" if some records were found, or _
'"do something else" if no records are found.

Dim db As Database
Dim rec As Recordset
Dim intRecords As Integer
Dim stQDF As String

stQDF = "QPriceLookUp"

Set db = CurrentDb()
Set rec = db.OpenRecordset(stQDF)

' at this point in the code an error message displays that indicates: Too few 'parameters; expected 7

intRecords = rec.RecordCount

MsgBox "There are " & intRecords & " records in the Recordset QPriceLookUp"

Set db = Nothing

Exit Sub

MsgBox Err.Description
Resume Exit_CmdResearch_Click

End Sub

Can someone help me:

I'm not sure what I'm doing wrong, can someone please help me out.
I get a runtime error 3061: Too few parameters Expected 1 when I run the following code below.

Dim rst As DAO.Recordset

Set rst = CurrentDb.OpenRecordset("SELECT * FROM [FRL Codes] WHERE [20YR] like EQPAR132;")



Hi All,
I can't get this simple query wroking in my Code....I am getting following error while running it
"Run-time error 3061" Too Few Parameters, expected 2"

Here is my Code:

Dim Fname As String
Dim ID As Integer
Dim SSQL As String
Dim SSQL1 As String

Fname = Trim(List_Resource_Combo)
ID = Forms!Add_Project_Details!Oppt_ID

SSQL = "UPDATE Sales_Pipeline_Current SET [Sales_Pipeline_Current].R_List = Fname where [Sales_Pipeline_Current].oppt_Id = ID ;"

Set db = CurrentDb()
db.Execute (SSQL)

I made sure Both the variable (Fname and ID) are assigned values. Query runs fine in Access Query Wizard..


I'm getting a "too few parameters" error from this: "Set recordset = database.Openrecordset(strSQL)"

original SQL statement:
strSQL = "SELECT * FROM [CalendarInfo] " & _
"WHERE [Soc Sec] = " & Forms![Apprentice Information]![Soc Sec #] & _
" AND BeginningDate = #" & datFirstDate & "#"
error: "Too few parameters. Expected 2."

modified SQL statement:
strSQL = "SELECT * FROM [CalendarInfo] WHERE [Soc Sec] = Forms![Apprentice Information]![Soc Sec #]
AND BeginningDate = #" & datFirstDate & "#;"
error: "Too few parameters. Expected 3."

So that you can see the context, here's the surrounding code, I've moved strSQL to two lines so that it will display as code without moving past the edge of the screen.

	Dim db As DAO.Database, rst As DAO.Recordset
Dim datFirstDate As Date, datLastDate As Date, strSQL As String
Dim intStart As Integer, intEnd As Integer, intI As Integer, strNum As String

    ' If no group is set
    If IsNull(Me![Names Combo Box]) Then
        Exit Sub
    End If
    ' Get a pointer to the current database
    Set db = CurrentDb
    ' Calculate the start and end date for the current month
    datFirstDate = DateSerial(intYear, intMonth, 1)
    datLastDate = DateSerial(intYear, intMonth, intLastDay)
    ' Set up to select the clubs and contract that are in
    '  the current month
    strSQL = "SELECT * FROM [CalendarInfo] " & _
        "WHERE [Soc Sec] = Forms![Apprentice Information]![Soc Sec #]
AND BeginningDate = #" & datFirstDate & "#;"
    Set rst = db.OpenRecordset(strSQL)

I have a form with 2 subforms.
There are various dropdowns on the the first subform, which set the recordsource for the form and can be changed continually.
The recordource is determined from some queries which have parameters like

All the drop downs work correctly and data is changed accordingly so the queries must be picking up the parameters from the form correctly.

However, when I try to export this to Excel, I get a "too few parameters. Expected 1" error even though it is trying to use excatly the same recordsource.

Any ideas why ?

Private Sub cmd_Export_Click()

Dim iCount As Integer
Dim strCell As String

iCount = DCount("
", Form.RecordSource)

'Main recordset with level codes
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim rst As DAO.Recordset

Set db = CurrentDb
Set rs = db.OpenRecordset(Form.RecordSource, dbOpenSnapshot)

'Start a new workbook in Excel
Dim oApp As New Excel.Application
Dim oBook As Excel.workBook
Dim oSheet As Excel.workSheet

Set oBook = oApp.Workbooks.Add
Set oSheet = oBook.Worksheets(1)

'Add the field names in row 1
Dim i As Integer
Dim iNumCols As Integer
iNumCols = rs.Fields.Count
For i = 1 To iNumCols
oSheet.Cells(1, i).Value = rs.Fields(i - 1).Name

'Add the data starting at cell A2
oSheet.Range("A2").CopyFromRecordset rs

'Format the header row as bold and autofit the columns
With oSheet.Range("a1").Resize(1, iNumCols)
.Font.Bold = True
End With

With oSheet
'now delete all data for previous months as it's not needed on the spreadsheet
.Columns("Z").Delete Shift:=xlToLeft
.Columns("R:X").Delete Shift:=xlToLeft
.Columns("O").Delete Shift:=xlToLeft
.Columns("G:M").Delete Shift:=xlToLeft
End With

'Top 10 recordset
Set rst = db.OpenRecordset(Forms!TabsReport!Top10Debtors_BU. Form.RecordSource, dbOpenSnapshot)

'Add the field names in row 1
iNumCols = rst.Fields.Count

For i = 1 To iNumCols
oSheet.Cells(iCount + 16, i).Value = rst.Fields(i - 1).Name

'Format the header row as bold and autofit the columns
strCell = "A" & iCount + 16
With oSheet.Range(strCell).Resize(1, iNumCols)
.Font.Bold = True
End With

'Add the data starting at cell A?
strCell = "A" & iCount + 17
oSheet.Range(strCell).CopyFromRecordset rst

'Format the sheet as per Finance template
With oSheet
.Rows("1:1").Insert Shift:=xlDown
.Rows("1:1").Insert Shift:=xlDown
.Rows("1:1").Insert Shift:=xlDown
.Rows("1:1").Insert Shift:=xlDown
.Range("A3").Value = "(1) Debt Summary (£ 000's)"
.Range("A3").Font.Underline = xlUnderlineStyleSingle

.Range("A" & iCount + 7).Value = "Totals"
.Range("A" & iCount + 8).Value = "Totals Last Month"
.Range("A" & iCount + 9).Value = "Variance"
.Range("A" & iCount + 7 & ":A" & iCount + 9).Font.Bold = True

.Range("A" & iCount + 11).Value = "(2) Percentage Ageing"
.Range("A" & iCount + 11).Font.Underline = xlUnderlineStyleSingle

.Range("A" & iCount + 13).Value = "Current Month"
.Range("A" & iCount + 14).Value = "Ageing Last Month"
.Range("A" & iCount + 15).Value = "Variance"

.Range("A" & iCount + 18).Value = "(3) Top 10 Bad Debt Provisions"
.Range("A" & iCount + 18).Font.Underline = xlUnderlineStyleSingle


End With

'Tidy up
oApp.Visible = True
oApp.UserControl = True

'Close the Database and Recordset

Set rs = Nothing
Set rst = Nothing
Set db = Nothing
Set oBook = Nothing
Set oSheet = Nothing
Set oApp = Nothing
End Sub

I have an append query that is called thus:

	CurrentDb.Execute "_qry_PopulateTableUnionTemp"

It used to work fine, no problems, but I have made some minor changes to my db and now the code fails on this line with the message "runtime error 3061: Too few parameters Expected 2". What I don't get is that if I run the query directly by double-clicking in it then it works fine, but not in code.
I have searched this forum for this error and read lots, but nothing that I can relate directly to this! Please help!

I currently have a listbox in one of my forms, when selected and delete is pressed i wish to delete this item from the list .
This is what i have been trying

Code: ( vb )
If MsgBox("Would you like to delete?", vbYesNo, "Confirmation") = vbYes Then
Set rstDelete = CurrentDb.OpenRecordset("SELECT * FROM tblorderlist WHERE productID = " & 1stlistbox)
End if

an error message is being displayed suggesting
too few parameters expected 1.

Would anyone know what that means.?

Not finding an answer? Try a Google search.