Too few parameters

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Busbait
    New Member
    • Sep 2007
    • 18

    Too few parameters

    when I run the below Code :
    Code:
    Dim dbsCurrent As Database
    Set dbsCurrent = CurrentDb
    
    dbsCurrent.Execute "INSERT INTO [Product information] ([Product Name]) VALUES " & "(" & [NewProdName] & ")"
    I get the following error message " Too few parameters. Expected 1. (Error 3061)"
    can some one help me with this issue?
    Last edited by NeoPa; Nov 30 '09, 02:11 PM. Reason: Please use the [CODE] tags provided.
  • ChipR
    Recognized Expert Top Contributor
    • Jul 2008
    • 1289

    #2
    Where are you running this code?
    What type of field is [Product Name]?

    Comment

    • ajalwaysus
      Recognized Expert Contributor
      • Jul 2009
      • 266

      #3
      Try this:
      Code:
      DoCmd.RunSQL("INSERT INTO [Product information] ([Product Name]) VALUES ('" & [NewProdName] & "')")
      And make sure that [NewProdName] has a value in it, to do this, put this before the code above:
      Code:
      Call MsgBox([NewProdName])
      Also, don't forget to answer ChipR's questions.

      -AJ

      Comment

      • Busbait
        New Member
        • Sep 2007
        • 18

        #4
        I am running this code via the Forms of MS Access and [Product Name] is Text

        Comment

        • ChipR
          Recognized Expert Top Contributor
          • Jul 2008
          • 1289

          #5
          This tutorial has a section on Data Type Qualifiers that explains part of the problem. The rest of the page should also be helpful.

          Comment

          • Busbait
            New Member
            • Sep 2007
            • 18

            #6
            Thanks to both of you , the code works fine now

            Comment

            • NeoPa
              Recognized Expert Moderator MVP
              • Oct 2006
              • 32656

              #7
              Notice also how AJ included the opening parenthesis in the previous string literal, rather than adding a separate one. It works the same but is less cumbersome ;)

              Comment

              Working...