473,325 Members | 2,792 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

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.

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
5 1212
twinnyfo
3,653 Expert Mod 2GB
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
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
5,501 Expert Mod 4TB
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
3,653 Expert Mod 2GB
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
32,556 Expert Mod 16PB
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

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

Similar topics

8
by: Tahir Hashmi | last post by:
Consider this piece of code: #include <iostream> using namespace std; class y { public: void draw()
3
by: colm | last post by:
i get the above runtime error on the following line of code when i try to update a reord in my form when it gets to the line Set rs = DBEngine(0)(0).OpenRecordset(strSql) the entire code...
2
by: fanfromfla | last post by:
I am using a database that has worked for many years for a holiday project for needy families. My organization recently upgraded its server and changed everyone to Windows XP. I just mention that...
4
by: Richard Hollenbeck | last post by:
I thought I was very specific in this SQL request. There is a form open with a selected record (and a corresponding "lngRecipeID" on that form. The table also has a field called "lngRecipeID". ...
4
by: JH001A | last post by:
ACCESS 2003 VBA in the code below set.rs3, gets the error when I try using a parm for input to the where clause. If I use a number like the one comented out it works. Thanks for your help. ...
10
RMWChaos
by: RMWChaos | last post by:
WinVista/IE7 I am getting some weird errors only in IE7, but not in FF2.0.0.8 or NN9. It even happens on this website when I click "Sign In". The error is: "A Runtime Error has occurred."...
1
by: istya | last post by:
I am having a dumb day to day. Can anyone have a schufty at my code and see why I am getting the runtime error 3061? I'm working on 2000 if that helps at all. Dim dbs As DAO.Database Dim...
3
by: phill86 | last post by:
Hi, I am trying to run the following query in a recordset and i get the following error message Runtime error 3061 - Too few parameters. Expected 1 i am using the following code
4
by: shalskedar | last post by:
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"...
8
by: Viv Jones | last post by:
Hi I am trying to update a recordset, however, I cannot get the code to run as i get Runtime Error: 3061. Too Few Parameters. Expected 1. Line 6 is highlighted when you debug. Any assistance...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.