"Runtime error 3061..Too many few parameters..Expected 1"

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • shalskedar
    New Member
    • Sep 2009
    • 66

    "Runtime error 3061..Too many few parameters..Expected 1"

    In my DB(Ms Access 2003)I want to delete a record from 1 table which is linked to another table.

    For ex- There are 2 tables "MasterType " which is the Master table & another table as "Sash DO" which is linked to this master table..Both the tables are linked by 1 common field as "Type"

    I've designed a form with a TextBox in such a way that the user needs to enter the Type name which is to be deleted..

    below is the vba code used in procedure to delete the particular Type.



    Code:
    Dim str As String
    Dim db As DAO.Database
    'Application.Run "aouters"
    Dim rs As DAO.Recordset
    Set db = CurrentDb
    
    Set rs = db.OpenRecordset("Sash DO")
    
    str = "delete from Sash DO where Type='" & Me.[Text4] & "'"
    db.Execute (str)
    End Sub
    After executing this it gives me an error "Runtime error 3061..Too many few parameters..Exp ected 1"
    Can any one help with some solution for this...

    Thanks in advance,
  • code green
    Recognized Expert Top Contributor
    • Mar 2007
    • 1726

    #2
    When running just the query, this wonderful error usually means you have got a table field name wrong.
    Check the spelling, check you are referring to the right table,
    check you are using the correct database(yes this is not unusual).

    If the query is fine then it is a problem with how you are referencing the classes

    Comment

    • Stewart Ross
      Recognized Expert Moderator Specialist
      • Feb 2008
      • 2545

      #3
      Code Green is spot on. The table name in line 9 has a space in it. The name as a whole should be enclosed in brackets:

      Code:
      str = "delete from [Sash DO] where Type='" & Me.[Text4] & "'"
      -Stewart

      Comment

      • ADezii
        Recognized Expert Expert
        • Apr 2006
        • 8834

        #4
        You have created a Recordset (rs) based on a Table (Sahs Do), while at the same time attempting to DELETE a Record(s) from the very same Table via an SQL Statement. Not really a good idea!

        Comment

        • Stewart Ross
          Recognized Expert Moderator Specialist
          • Feb 2008
          • 2545

          #5
          Well-spotted ADezii. The recordset statement has no relation to and no bearing on the success of the Execute command you are using to delete the record. It is not required and should be deleted.

          -Stewart

          Comment

          Working...