Results 1 to 7 of 7
  1. #1
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,185

    Run Time Error 3061

    Hi Guy's, i am getting a runtime error 3061 too few parameters. expected 1.



    rs is set as Dao.Recordset
    strCustName is String
    InvNo is Integer and record exists ??

    Kindest

    Code:
    Set rs = CurrentDb.OpenRecordset("SELECT tblInvoices.tblInvoiceNumber, tblInvoices.InvoiceDate," _
    & "tblInvoices.Customer, tblInvoices.Add1, tblInvoices.Add2, tblInvoices.Town, tblInvoices.PostCode," _
    & "tblInvoices.InvoiceDetails, tblInvoices.Amount FROM tblInvoices WHERE Customer = '" & strCustName & "'" & " And InvoiceNumber = " & InvNo)
    

  2. #2
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,397
    error indicates a typo or missing or empty control

    better to assign your sql string to a string variable and debug.print it. That may be sufficient to see the code is incorrect. If not obvious then copy and paste the string to a new query

  3. #3
    JoeM is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    Also, be sure to check the Data Type of the InvoiceNumber field. If it is Text/String, you will need single quotes around that value too (like you did for strCustName).

  4. #4
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    not & InvNo)

    but

    & InvNo & ")"


    Never mind. I see that's incorrect.
    Last edited by Micron; 10-22-2019 at 08:35 AM.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  5. #5
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,185
    Hi Guy's thank you for your replies, i think i may have found the problem, i didn't have Microsoft DAO 3.6 checked in references, when i do, it comes up with a conflict
    Click image for larger version. 

Name:	Capture3.JPG 
Views:	15 
Size:	15.9 KB 
ID:	39996

    Where is the problem here ? I do have these references checked in another database but won't allow me in this one, db name is different, I thought that db name was the conflict but unsure, any ideas ??

    Kindest Regards

  6. #6
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,397
    dao is standard in Access, you don't need the library - you would use the library in say Excel or Word. What happens if you debug.print the string?

  7. #7
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    References apply to the project, not all databases. Assuming all is spelled correctly, all data types are properly defined and delimited, nothing is Null or "" then suggest you assign the sql string to a variable and Debug.Print out the variable before the recordset line. You can use the variable in the recordset line. If it all looks OK and all is correct as noted above, then I don't know because you're not using form references. Often it is best to paste the output in the immediate window into a new query sql view and attempt to switch to datasheet view. If it balks, it usually highlights the offending part. If it runs, something else is wrong.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Run-Time Error 3061
    By lefty2cox in forum Programming
    Replies: 7
    Last Post: 02-21-2016, 07:33 AM
  2. Run time error 3061
    By beaurou in forum Modules
    Replies: 18
    Last Post: 02-23-2015, 11:54 AM
  3. Run-Time Error 3061
    By GraeagleBill in forum Programming
    Replies: 2
    Last Post: 09-23-2013, 06:46 AM
  4. Run-time error 3061
    By boywonder in forum Programming
    Replies: 1
    Last Post: 07-20-2011, 06:14 AM
  5. Run-Time error 3061
    By boywonder in forum Programming
    Replies: 12
    Last Post: 05-24-2011, 10:15 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums