UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Docmd.runsql Error, Access 2016    
 
   
tpitman
post Feb 18 2020, 05:09 AM
Post#1



Posts: 631
Joined: 20-June 04
From: UK


Hi

I am getting the following message when trying to run this DoCmd.RunSQL command

"Syntax Error in Update Statement"

Can someone point me in the right direction please?

I am using a variable g1Minstr for the SET



dim strSQL as string

strSQL = "UPDATE CurrentVals-Chamber1 SET MinTMN = " & g1Minstr & ";"

DoCmd.RunSQL strSQL
Go to the top of the page
 
cheekybuddha
post Feb 18 2020, 06:05 AM
Post#2


UtterAccess Moderator
Posts: 12,622
Joined: 6-December 03
From: Telegraph Hill


Hi,

What datatype is your variable g1Minstr?

More importantly, what datatype is field MinTMN?

From your variable name, I'm guessing it's a string.

String values must be delimited by quote marks in an SQL statement.

Try:
CODE
  Dim strSQL as string

  strSQL = "UPDATE [CurrentVals-Chamber1] SET MinTMN = '" & g1Minstr & "';"
  CurrentDb.Execute strSQL, dbFailOnError


I wrapped your table name in square brackets because it contains a dash, which might be interpreted as an arithmetic minus sign and causing an issue as well.

It you use CurrentDb.Execute you don't get the annoying "Are you sure ...?" messages.

hth,

d

--------------------


Regards,

David Marten
Go to the top of the page
 
tpitman
post Feb 18 2020, 06:22 AM
Post#3



Posts: 631
Joined: 20-June 04
From: UK


Many thanks!!
Go to the top of the page
 
cheekybuddha
post Feb 18 2020, 06:56 AM
Post#4


UtterAccess Moderator
Posts: 12,622
Joined: 6-December 03
From: Telegraph Hill


yw.gif

--------------------


Regards,

David Marten
Go to the top of the page
 


Custom Search


RSSSearch   Top   Lo-Fi    8th April 2020 - 03:36 PM