Run-time error 3061. Too Few Parameters. Expected 2.

Discussion in 'Access VBA Modules' started by Know39, Sep 27, 2011.

  1. Know39

    Know39 Guest

    The following is SQL code from a function that works fine in our
    current database. After changing the data source to a new database
    suddenly it throws the 3061 error.

    The error occurs whether the Original line or the Test line was used.
    I checked all spellings and are correct. The [Member Medical] is a
    query.

    Function getPlnCovDesc(EID As String)
    Dim mEmplClassCode As String
    Dim mBenPlan As String

    Dim rst As DAO.Recordset
    Dim mSQL As String


    'ORIGINAL LINE:
    mSQL = "Select * from [Member Medical] where EMPL_ID = '" & EID & "'"

    'TEST LINE:
    'mSQL = "Select EMPL_CLASS_CD, BEN_PLAN_CD from [Member Medical] where
    EMPL_ID='096553'"

    Set rst = db.OpenRecordset(mSQL) <-- 3061 Error. Too Few
    Parameters. Expected 2.
     
    Know39, Sep 27, 2011
    #1
    1. Advertisements

  2. Are you positive those two fields exist in the table exactly as typed in
    your SQL?

    "Know39" wrote in message
    news:...

    The following is SQL code from a function that works fine in our
    current database. After changing the data source to a new database
    suddenly it throws the 3061 error.

    The error occurs whether the Original line or the Test line was used.
    I checked all spellings and are correct. The [Member Medical] is a
    query.

    Function getPlnCovDesc(EID As String)
    Dim mEmplClassCode As String
    Dim mBenPlan As String

    Dim rst As DAO.Recordset
    Dim mSQL As String


    'ORIGINAL LINE:
    mSQL = "Select * from [Member Medical] where EMPL_ID = '" & EID & "'"

    'TEST LINE:
    'mSQL = "Select EMPL_CLASS_CD, BEN_PLAN_CD from [Member Medical] where
    EMPL_ID='096553'"

    Set rst = db.OpenRecordset(mSQL) <-- 3061 Error. Too Few
    Parameters. Expected 2.
     
    Douglas J Steele, Sep 28, 2011
    #2
    1. Advertisements

  3. Know39

    Phil Guest

    On 28/09/2011 22:38:03, "Douglas J Steele" wrote:
    > Are you positive those two fields exist in the table exactly as typed in
    > your SQL?
    >
    > "Know39" wrote in message
    > news:...
    >
    > The following is SQL code from a function that works fine in our
    > current database. After changing the data source to a new database
    > suddenly it throws the 3061 error.
    >
    > The error occurs whether the Original line or the Test line was used.
    > I checked all spellings and are correct. The [Member Medical] is a
    > query.
    >
    > Function getPlnCovDesc(EID As String)
    > Dim mEmplClassCode As String
    > Dim mBenPlan As String
    >
    > Dim rst As DAO.Recordset
    > Dim mSQL As String
    >
    >
    > 'ORIGINAL LINE:
    > mSQL = "Select * from [Member Medical] where EMPL_ID = '" & EID & "'"
    >
    > 'TEST LINE:
    > 'mSQL = "Select EMPL_CLASS_CD, BEN_PLAN_CD from [Member Medical] where
    > EMPL_ID='096553'"
    >
    > Set rst = db.OpenRecordset(mSQL) <-- 3061 Error. Too Few
    > Parameters. Expected 2.
    >
    >


    Is EID numeric or text? Assuning it is numeric (ID's usually are), you don't
    need the quotes mSQL = "Select * from [Member Medical] where EMPL_ID = " &
    EID & ";"

    Incidently, you will get more replies from a newsgroup like
    comp.databases.ms_access

    Phil
     
    Phil, Sep 30, 2011
    #3
    1. Advertisements

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Similar Threads
  1. Marin
    Replies:
    4
    Views:
    194
    Geoff
    Jul 30, 2003
  2. michael c

    Runtime Error 3061. Too Few Parameters. Expected 8.

    michael c, Nov 18, 2003, in forum: Access VBA Modules
    Replies:
    2
    Views:
    304
    Dirk Goldgar
    Nov 18, 2003
  3. andrew3254

    Error 3061: Too few parameters...

    andrew3254, Aug 10, 2007, in forum: Access VBA Modules
    Replies:
    2
    Views:
    136
    Ofer Cohen
    Aug 10, 2007
  4. BlueWolverine

    OpenRecordset fails Error 3061 too few params expected 12

    BlueWolverine, Jul 9, 2008, in forum: Access VBA Modules
    Replies:
    6
    Views:
    243
    Douglas J. Steele
    Jul 9, 2008
  5. noname

    Error 3061: Too few parameters. Expected 1

    noname, Aug 11, 2008, in forum: Access VBA Modules
    Replies:
    1
    Views:
    149
    Paolo
    Aug 11, 2008
  6. Gary S
    Replies:
    4
    Views:
    232
    Gary S
    Feb 19, 2009
  7. BlueWolverine

    ERROR 3061 - Too few parameters

    BlueWolverine, Sep 21, 2009, in forum: Access VBA Modules
    Replies:
    1
    Views:
    130
    Dirk Goldgar
    Sep 21, 2009
  8. dbguru316

    Error 3061 - too few parameters

    dbguru316, Dec 8, 2009, in forum: Access VBA Modules
    Replies:
    2
    Views:
    124
    dbguru316
    Dec 8, 2009
Loading...