473,508 Members | 2,425 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

RunSql UPDATE almost Working

2 New Member
I am working on a document tracking database (access) and I want the user to select a document number from a combo box, which then updates all the textboxes. Then the user can update the fields then click an update button. This almost works but when I run the below SQL and supplemental code. I get the below error (I had to put some generic names in for confidentiality aslo "Test123" is entered into textbox:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command55_Click()
  2. Dim TempStr As String
  3.  
  4. TempStr = Me.dcrSubjectOfChange_TB.Value //from Combo
  5.  
  6. DoCmd.RunSQL ("UPDATE [DB_Company] SET DB_Company.SubjectOfChange = " & TempStr & "WHERE DB_Company.DocNum = Forms!Form_Edit_Current!Doc_Num_CB")
  7.  
  8. End Sub
Syntax error (missing operator) in query expression 'Test123Where DB_Company.DocNum = Forms!Form_Edit_Current!Doc_Num_CB

//////////////////////////////////////////

So this leads me to believe the string variable is getting recognized correctly so therefore I must have a sql syntax error. Thanks in Advance
Dec 7 '11 #1
2 1497
Rabbit
12,516 Recognized Expert Moderator MVP
You're missing a space.
... TempStr & " WHERE ...
Basically, if TempStr is bob then
TempStr & "where" = bobwhere
TempStr & " where" = bob where

Also, if SubjectOfChange is a text data type, you will need to surround TempStr with quotes in the SQL string.
Dec 7 '11 #2
Cole S
2 New Member
Thanks a lot. Should have thought of that myself, it was right in front of me. Works like a charm now

@Rabbit
Dec 7 '11 #3

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

Similar topics

4
10173
by: Rotsj | last post by:
Hi, i try to execute an update query from within a form, but i get the message: run time error '3144'. Syntax error on the update statement when i try something like this: DoCmd.RunSQL...
8
11202
by: RC | last post by:
In my Access 2002 form, I have a combo box and on the AfterUpdate event I use DoCmd.RunSQL ("UPDATE .... to update records in a table. When it starts to run I get a message "You are about to...
5
4159
by: HydroSan | last post by:
Having a bit of a problem getting UPDATE working. The project in question is a simple MySQL VB.NET frontend, allowing Insertion, Selection, and others. Well, I've gotten Drop and Insert working,...
1
1363
markmcgookin
by: markmcgookin | last post by:
This is a strange one! One minute, everything worked fine, then suddenly I don't know if i did anything, but this started happening. I have a listbox, populated with 3 values (UserID, userName...
1
4077
by: TriednTested | last post by:
Hello I have a subform and to edit the data I place it on the main form where changes can be made, then a cmd button is used to execute the docmd.runsql update query. However I am constantly getting...
5
1370
by: qatarya3sal | last post by:
Imports System.XML Public Class Form1 Inherits System.Windows.Forms.Form Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load ...
11
1481
by: Peter Webb | last post by:
I previously asked about two problems I had with some graphics - the first was that when I drew animation to a picturebox it wouldn't display when the Form loaded. It was suggested to me by...
61
5246
by: bonneylake | last post by:
Hey Everyone, Well after asking many questions i have this almost working. This is how it works. Basically i fill in my customer number field an that populates my drop down box. Once i select...
9
3007
by: mrcheeky | last post by:
Hi, I'm stuck, but it's almost working! From a html page, my javascript calls a server-side php script. The php reads a value from a server-side .txt file and passes it back as a javascript...
3
3695
by: fishnfrogs | last post by:
Hi, I can't figure out why this isn't working. I'm trying to loop through an array and do a mysql update. However, it doesn't work. for($i = 0; $i < $len; ++$i) { $param = $array . '%';...
0
7118
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7379
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7038
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7493
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5625
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4706
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3192
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3180
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
763
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.