Question Update table by SQL command

byTimber

Registered User.
Local time
Today, 13:34
Joined
Apr 14, 2012
Messages
97
The following code does the job to put tagname (a variable) into NumberStatement field in the table:-

SQLquery = "UPDATE [lvrstatements1] SET [NumberStatement] = '" & tagName & "' "
DoCmd.RunSQL SQLquery


BUT I need;

To SET the field in the table to Variable1 + variable2 (e.g to NumberStatement2 with NumberStatement being Variable1 and 2 being Variable2)

Any ideas?

Thanks...
 
i may be misreading this but it seems you just need to add the 2 variables - Variable1 + variable2 - together. If they are numbers just add if they are text then use & to join them together.
  • Numbers
    • SQLquery = "UPDATE [lvrstatements1] SET [NumberStatement] = '" & ltrim(str(Variable1 + variable2 )) & "' "
  • Text
    • SQLquery = "UPDATE [lvrstatements1] SET [NumberStatement] = '" & (Variable1 & variable2) & "' "
    • OR
      tmpVar = Variable1 & variable2
      SQLquery = "UPDATE [lvrstatements1] SET [NumberStatement] = '" & tmpVar & "' "
 
Thanks for response isskint but I need the 2 variables added together (makes the field I'm addressing) to SET. The tagName is the variable which is the value that I want to insert into the table.
Like SET [Variable1 + Variable2] = '" & tagName & "' "
How to add these 2 Variables is my problem..
 
So you want to UPDATE more than 1 field, is that correct? If so then try this:

SQLquery = "UPDATE [lvrstatements1] SET [NumberStatement] = '" & variable1 & "' ", [NumberStatement2] = '" & variable2 & "' ";
 
No Isskint not 2 fields; 1 field; I have a field named NumberStatement3 and need to pass both the 'NumberStatement" and the "3" as variables to SET.

e.g Variable1 = "NumberStatement"
Variable2 = "3"

SET [Variable1 + Variable2] = tagname

These variables may change.
 

Users who are viewing this thread

Back
Top Bottom