Results 1 to 13 of 13
  1. #1
    boywonder is offline Advanced Beginner
    Windows 7 32bit Access 2003
    Join Date
    Dec 2010
    Location
    Memphis, TN
    Posts
    60

    Run-Time error 3061

    I'm getting an error 3061:



    Too Few parameters. Expected 3.

    This is the code I'm trying to use:

    k = rsTemp2!custno
    ChkNo = rsTemp2!checknumber

    Set rsQry2 = db.OpenRecordset("Select * from transactions " _
    & "WHERE (((tranactions.[custno])= " & k & " AND " _
    & "tranactions.[check number] = '" & ChkNo & "')) ORDER BY tranactions.date DESC;")

  2. #2
    nicknameoscar is offline Advanced Beginner
    Windows XP Access 2000
    Join Date
    Apr 2011
    Location
    Earlysville, VA
    Posts
    91
    Is that last closing ) supposed to be there? I don't think it is.

  3. #3
    boywonder is offline Advanced Beginner
    Windows 7 32bit Access 2003
    Join Date
    Dec 2010
    Location
    Memphis, TN
    Posts
    60
    The one after the DESC;"

  4. #4
    nicknameoscar is offline Advanced Beginner
    Windows XP Access 2000
    Join Date
    Apr 2011
    Location
    Earlysville, VA
    Posts
    91
    Maybe I am wrong but maybe the below is more correct:

    "WHERE (((tranactions.[custno])= " & k & ")" AND " _
    & "((tranactions.[check number]) = '" & ChkNo & "')) ORDER BY tranactions.date DESC;"

    I keep forgetting the rules about the single and double quotes (have to refer to reference material each time) so I am not sure of how you have mixed them around ChkNo.

  5. #5
    boywonder is offline Advanced Beginner
    Windows 7 32bit Access 2003
    Join Date
    Dec 2010
    Location
    Memphis, TN
    Posts
    60
    The k is an integer and the Chkno is a string.

  6. #6
    boywonder is offline Advanced Beginner
    Windows 7 32bit Access 2003
    Join Date
    Dec 2010
    Location
    Memphis, TN
    Posts
    60
    Now I'm getting the Run-time error 13: Type mismatch

  7. #7
    nicknameoscar is offline Advanced Beginner
    Windows XP Access 2000
    Join Date
    Apr 2011
    Location
    Earlysville, VA
    Posts
    91
    Sorry, what I meant about the single and double quotes was that I kept them the same way as yours but I wasn't sure if they were correct. They may be correct but I use books for reference (vs. the Internet) and I don't have the book with me to check. Sorry, I am an old geezer too set in his ways.

    This what I do:

    & """" & ChkNo & """" & ")) ORDER BY tranactions.date DESC;"
    Last edited by nicknameoscar; 05-24-2011 at 09:15 AM. Reason: correction

  8. #8
    boywonder is offline Advanced Beginner
    Windows 7 32bit Access 2003
    Join Date
    Dec 2010
    Location
    Memphis, TN
    Posts
    60
    That didn't work.

    Set rsQry2 = db.OpenRecordset("Select * from transactions " _
    & "WHERE (((tranactions.[custno])= " & k & ")" And "" _
    & "((tranactions.[check number]) = & """" & ChkNo & """" & ") ORDER BY tranactions.date DESC;")

    Now I'm getting a syntax error.

    What I'm trying to do is find the records of a customer and their check number.

  9. #9
    nicknameoscar is offline Advanced Beginner
    Windows XP Access 2000
    Join Date
    Apr 2011
    Location
    Earlysville, VA
    Posts
    91
    Apologies again, I now see why that closing ) is necessary. I don't have any other ideas.

  10. #10
    nicknameoscar is offline Advanced Beginner
    Windows XP Access 2000
    Join Date
    Apr 2011
    Location
    Earlysville, VA
    Posts
    91
    Maybe try this:

    Set rsQry2 = db.OpenRecordset("Select * from transactions " _
    & "WHERE (((tranactions.[custno])=" & k & ") And " _
    & "((tranactions.[check number])=" & """" & ChkNo & """" & ") ORDER BY tranactions.date DESC;")

  11. #11
    boywonder is offline Advanced Beginner
    Windows 7 32bit Access 2003
    Join Date
    Dec 2010
    Location
    Memphis, TN
    Posts
    60
    Getting a Run-Time error 3075:

    Syntax error (missing operator) in query expression
    '(((transactions.[custno])=102 AND ((transactions.[check
    number])="786") ORDER BY transactions.date DESC;'.

  12. #12
    boywonder is offline Advanced Beginner
    Windows 7 32bit Access 2003
    Join Date
    Dec 2010
    Location
    Memphis, TN
    Posts
    60
    I look at one of my old apps and used this:

    Set rsQry2 = db.OpenRecordset("Select * from transactions " _
    & "WHERE (((transactions.[custno])= " & k & " And " _
    & "transactions.[check number]= '" & ChkNo & "')) " _
    & "ORDER BY transactions.date DESC;")

    I put a space after the = and changed the ChkNo item quotations and it worked. Thanks nicknameoscar for all your help. We did it!

  13. #13
    nicknameoscar is offline Advanced Beginner
    Windows XP Access 2000
    Join Date
    Apr 2011
    Location
    Earlysville, VA
    Posts
    91
    If you are game try this:

    Set rsQry2 = db.OpenRecordset("Select * from transactions " _
    & "WHERE (((tranactions.[custno])=" & k & ") And " _
    & "((tranactions.[check number])=" & """" & ChkNo & """" & ")) ORDER BY tranactions.date DESC;")

    Please accept my apologies for all the screwups. I am entirely too dependent on using the QBE in Access. I build the queries and then copy/paste the SQL statement into my code.

    I am surprised that the experts haven't called me out :-) .

    So ignore the above except my apology. You replied while I was writing.
    Last edited by nicknameoscar; 05-24-2011 at 10:16 AM. Reason: OP replied while I was writing.

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

Similar Threads

  1. Replies: 1
    Last Post: 05-21-2011, 01:33 AM
  2. Error 3061 Too Few Parameters Expecting 1
    By ironman in forum Programming
    Replies: 4
    Last Post: 05-09-2011, 03:20 PM
  3. db.Execute Error 3061
    By JimG in forum Programming
    Replies: 5
    Last Post: 05-17-2010, 09:34 AM
  4. Error 3061 in VBA program
    By fbou in forum Programming
    Replies: 5
    Last Post: 10-07-2009, 11:00 AM
  5. Error 3061
    By Shanks in forum Queries
    Replies: 4
    Last Post: 09-16-2009, 07:13 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