Mark
Mark

Reputation: 1872

VBA SQL Syntax Problems

I have the following SQL:

SQL = "UPDATE [TBLTMP] SET TBLTMP24 '" & Me.TOWN & "' WHERE TBLTMP00 = '" & "1" & "';"


Table name TBLTMP
Field to update TBLTMP24
Record to update TBLTMP00

I want to store the value of ‘Me.Town’ in the field TBLTMP24 which is in the table TBLTMP, record number 1, anyone have any ideas what might work?

Upvotes: 0

Views: 67

Answers (2)

Bla...
Bla...

Reputation: 7288

I think all you need is to add = into your query, like below:

SQL = "UPDATE TBLTMP SET TBLTMP24 = '" & Me.TOWN & "' WHERE TBLTMP00 = '" & "1" & "';"

If you want to change some columns add commas, like below:

SQL = "UPDATE TBLTMP SET TBLTMP24 = '" & Me.TOWN & "', another_col = '" & Me.another & "' WHERE TBLTMP00 = '" & "1" & "';"

Upvotes: 0

Gareth
Gareth

Reputation: 5243

You're missing an = in your SQL Statement after TBLTMP24. You're statement should be:

SQL = "UPDATE [TBLTMP] SET TBLTMP24 = '" & Me.TOWN & "' WHERE TBLTMP00 = '" & "1" & "';"

Upvotes: 1

Related Questions