DoCmd.RunSQL Update Help

xljunkie

Board Regular
Joined
May 20, 2011
Messages
92
I have a table with 2 columns - VarName and VarValue. I want to update the record where VarName is "ImportFullDate" a text string. The text string is stored in a variable in my VBA code as ImportFullDate.

I'm not sure if my quotes are off or if I have other things in this statement that are off.

Code:
DoCmd.RunSQL "UPDATE [tblVariables] SET [VarValue] = ImportFullDate WHERE [tblVariables].[VarName]='" & ImportFullDate & "'"
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
I changed it to this and I'm getting a syntax error in number

Code:
DoCmd.RunSQL "UPDATE [tblVariables] SET [VarValue] = " & ImportFullDate & " WHERE [tblVariables].[VarName]= 'ImportFullDate'"

The variable ImportFullDate is a text string, yet it's trying to interpret it as a number?
 
Upvote 0
Got it to work with this:

Code:
DoCmd.RunSQL "UPDATE [tblVariables] SET [VarValue] = '" & ImportFullDate & "' WHERE [tblVariables].[VarName]= 'ImportFullDate'"
 
Upvote 0

Forum statistics

Threads
1,221,877
Messages
6,162,583
Members
451,776
Latest member
bosvinn

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top