Run-time error '3061': Too few parameters. Expected 1

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mary2210
    New Member
    • Jun 2014
    • 2

    Run-time error '3061': Too few parameters. Expected 1

    Hi,
    Iam getting this error when I try to update a query for a Form of MS Access.
    How can I resolve this. Please help.

    Code:
    CurrentDb.Execute "UPDATE IQStudents SET Tnumber= '& Me.txtTnumber &', FirstName= '& Me.txtFirstName &' , MI='& Me.txtMI &' , LastName='& Me.txtLastName &', CurrentlyEnrolled='& Me.chkCurrentlyEnrolled &' , Grad='& Form_IQStudentDetails.chkGrad &', LinkedIn= '& Me.hypLinkedI & ', Facebook=' & Me.hypFacebook & ', UAEmail=' & Me.hypUAEmail & ', PersonalWorkEmail1=' & Me.hypPersonalEmail1 & '" & _
                   ", PersonalWorkEmail2=' & Me.hypPersonalEmail2 & ', Address=' & Me.txtAddress & ', PhoneNumber=' & Me.txtPhoneNumber & ', FirstSemAdmitted=' & Me.cboFirstSemAdmitted & '" & _
                   ", LastSemAttended=' & Me.cboLastSemAttended & ', OnProbationorDismissed=' & Me.chkProborDismissed & ', AdmittedtoGC=' & Me.chkAdmittedtoGC & ', DateAwardedtoGC=' & Me.txtDateAwardedtoGC & '" & _
                   ", AdmittedtoMS=' & Me.chkAdmittedtoMS & ', DateAwardedtoMS=' & Me.txtDateAwardedtoMS & ', AdmittedtoPhD=' & Me.chkAdmittedtoPhD & ', DateAwardedtoPhD=' & Me.txtDateAwardedtoPhD & '" & _
                   ", Employer=' & Me.txtEmployer & ', Occupation=' & Me.txtOccupation & ', Notes=' & Me.txtNotes & ', Projects=' & Me.txtProjects & ', Sponsors=' & Me.txtSponsors & '" & _
                   ", Inventory=' & Me.txtInventory & ', AdditionalInventory=' & Me.txtAdditionalInventory & ', DrawerKeys=' & Me.txtDrawerKeys & '" & _
                   " Where Tnumber=" & Me.txtTnumber.Tag
    Last edited by zmbd; Jun 23 '14, 08:16 PM. Reason: [OP{Added complete query}][Z{Please use the [CODE/] button to format posted script and formated text - Please read the FAQ}]
  • twinnyfo
    Recognized Expert Moderator Specialist
    • Nov 2011
    • 3653

    #2
    mary2210,

    Do you really want your query to search for values of

    Code:
    Tnumber = & Me.txtTnumber.Tag
    That seems strange to use the Text Box's tag property for a query criteria, but it wouldbe possible--just never seen it done that way before.

    Was this a typo?

    Comment

    • mary2210
      New Member
      • Jun 2014
      • 2

      #3
      when I click on edit the values from sub form will be populated in Form fields and are used for update.

      Please find Edit functionality

      Code:
      Private Sub btnEdit_Click()
          'Check whether there exists data in list
             If Not (Me.IQStudentsSub.Form.Recordset.EOF And Me.IQStudentsSub.Form.Recordset.BOF) Then
              'Get data to form controls
                 With Me.IQStudentsSub.Form.Recordset
                      Me.txtTnumber = .Fields("Tnumber")
                      Me.txtFirstName = .Fields("FirstName")
                      Me.txtMI = .Fields("MI")
                      Me.txtLastName = .Fields("LastName")
                      Me.chkCurrentlyEnrolled = .Fields("CurrentlyEnrolled")
                      Me.chkGrad = .Fields("Grad")
                      Me.cboFirstSemAdmitted = .Fields("FirstSemAdmitted")
                      'Inventory details
                      Me.txtInventory = .Fields("Inventory")
                      Me.txtAdditionalInventory = .Fields("AdditionalInventory")
                      Me.txtDrawerKeys = .Fields("DrawerKeys")
                      
                      'Store TNumber incase if TNumber is modified
                      Me.txtTnumber.Tag = .Fields("Tnumber")
                      
                      'Change caption of button from Add to update
                      Me.btnAdd.Caption = "Update"
                                     
                      'disable button edit
                      Me.btnEdit.Enabled = False
                 
                 End With
            End If
      End Sub
      Last edited by zmbd; Jun 23 '14, 08:16 PM. Reason: [Z{Please use the [CODE/] button to format posted script and formated text - Please read the FAQ}]

      Comment

      • zmbd
        Recognized Expert Moderator Expert
        • Mar 2012
        • 5501

        #4
        mary2210

        Please, click on the [CODE/] button in the post toolbar and then cut and paste your script between the [CODE] [/CODE] tags.
        This is a site requirement.
        thnx

        Comment

        • twinnyfo
          Recognized Expert Moderator Specialist
          • Nov 2011
          • 3653

          #5
          Mary,

          As I am sure Z will also recommend, to help you trouble shoot your string, create a text string first, then run it:

          Code:
          Dim strSQL as String
          strSQL = "UPDATE IQStudents SET ....
          
          Debug.Print strSQL
          
          CurrentDb.Execute
          Also, you will want to take a very close look at all of your single and double quotes. It seems you are using singles when doubles are required:

          Code:
          "UPDATE IQStudents SET Tnumber = " & Me.txtTnumber & _
              ", FirstName = '" & Me.txtFirstName & ...
          Text fields will require the use of double quotes and inner single quotes. Numerical values require no single quotes.

          Please let m eknow if this gets you started in the right direction.

          Comment

          • NeoPa
            Recognized Expert Moderator MVP
            • Oct 2006
            • 32633

            #6
            How to Debug SQL String contains instructions on how best to go about this. Posting VBA code that should create a string is never a good idea.

            Comment

            Working...