By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,256 Members | 1,700 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,256 IT Pros & Developers. It's quick & easy.

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

P: 2
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.

Expand|Select|Wrap|Line Numbers
  1. 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 & '" & _
  2.                ", PersonalWorkEmail2=' & Me.hypPersonalEmail2 & ', Address=' & Me.txtAddress & ', PhoneNumber=' & Me.txtPhoneNumber & ', FirstSemAdmitted=' & Me.cboFirstSemAdmitted & '" & _
  3.                ", LastSemAttended=' & Me.cboLastSemAttended & ', OnProbationorDismissed=' & Me.chkProborDismissed & ', AdmittedtoGC=' & Me.chkAdmittedtoGC & ', DateAwardedtoGC=' & Me.txtDateAwardedtoGC & '" & _
  4.                ", AdmittedtoMS=' & Me.chkAdmittedtoMS & ', DateAwardedtoMS=' & Me.txtDateAwardedtoMS & ', AdmittedtoPhD=' & Me.chkAdmittedtoPhD & ', DateAwardedtoPhD=' & Me.txtDateAwardedtoPhD & '" & _
  5.                ", Employer=' & Me.txtEmployer & ', Occupation=' & Me.txtOccupation & ', Notes=' & Me.txtNotes & ', Projects=' & Me.txtProjects & ', Sponsors=' & Me.txtSponsors & '" & _
  6.                ", Inventory=' & Me.txtInventory & ', AdditionalInventory=' & Me.txtAdditionalInventory & ', DrawerKeys=' & Me.txtDrawerKeys & '" & _
  7.                " Where Tnumber=" & Me.txtTnumber.Tag
Jun 23 '14 #1
Share this Question
Share on Google+
5 Replies


twinnyfo
Expert Mod 2.5K+
P: 3,482
mary2210,

Do you really want your query to search for values of

Expand|Select|Wrap|Line Numbers
  1. 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?
Jun 23 '14 #2

P: 2
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

Expand|Select|Wrap|Line Numbers
  1. Private Sub btnEdit_Click()
  2.     'Check whether there exists data in list
  3.        If Not (Me.IQStudentsSub.Form.Recordset.EOF And Me.IQStudentsSub.Form.Recordset.BOF) Then
  4.         'Get data to form controls
  5.            With Me.IQStudentsSub.Form.Recordset
  6.                 Me.txtTnumber = .Fields("Tnumber")
  7.                 Me.txtFirstName = .Fields("FirstName")
  8.                 Me.txtMI = .Fields("MI")
  9.                 Me.txtLastName = .Fields("LastName")
  10.                 Me.chkCurrentlyEnrolled = .Fields("CurrentlyEnrolled")
  11.                 Me.chkGrad = .Fields("Grad")
  12.                 Me.cboFirstSemAdmitted = .Fields("FirstSemAdmitted")
  13.                 'Inventory details
  14.                 Me.txtInventory = .Fields("Inventory")
  15.                 Me.txtAdditionalInventory = .Fields("AdditionalInventory")
  16.                 Me.txtDrawerKeys = .Fields("DrawerKeys")
  17.  
  18.                 'Store TNumber incase if TNumber is modified
  19.                 Me.txtTnumber.Tag = .Fields("Tnumber")
  20.  
  21.                 'Change caption of button from Add to update
  22.                 Me.btnAdd.Caption = "Update"
  23.  
  24.                 'disable button edit
  25.                 Me.btnEdit.Enabled = False
  26.  
  27.            End With
  28.       End If
  29. End Sub
Jun 23 '14 #3

zmbd
Expert Mod 5K+
P: 5,397
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
Jun 23 '14 #4

twinnyfo
Expert Mod 2.5K+
P: 3,482
Mary,

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

Expand|Select|Wrap|Line Numbers
  1. Dim strSQL as String
  2. strSQL = "UPDATE IQStudents SET ....
  3.  
  4. Debug.Print strSQL
  5.  
  6. 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:

Expand|Select|Wrap|Line Numbers
  1. "UPDATE IQStudents SET Tnumber = " & Me.txtTnumber & _
  2.     ", 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.
Jun 23 '14 #5

NeoPa
Expert Mod 15k+
P: 31,768
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.
Jun 23 '14 #6

Post your reply

Sign in to post your reply or Sign up for a free account.