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. - 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
5 1212
mary2210,
Do you really want your query to search for values of - 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?
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 - 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
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
Mary,
As I am sure Z will also recommend, to help you trouble shoot your string, create a text string first, then run it: - 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: - "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.
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.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Tahir Hashmi |
last post by:
Consider this piece of code:
#include <iostream>
using namespace std;
class y
{
public:
void draw()
|
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...
|
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...
|
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". ...
|
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.
...
|
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."...
|
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...
|
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
|
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"...
|
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...
|
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...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
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...
|
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...
|
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...
|
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)...
|
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....
|
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
|
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...
| |