Run Time error with Update Query

chathag

Registered User.
Local time
Today, 22:01
Joined
May 22, 2009
Messages
32
I have the following piece of code that updates a field in a table with a selected value from a list box

Dim varItm As Variant
If IsNull(Me.tb_Other1) Then
DoCmd.RunSQL "UPDATE Tbl_Section_1 SET Tbl_Section_1.ProgUsed =" & Me.Lb_Programmes.ItemData(varItm) & _
" Where" & [Tbl_Section_1]![UniqueID] = Me.Tb_UniqueId
Else
DoCmd.RunSQL "UPDATE Tbl_Section_1 SET Tbl_Section_1.ProgUsed =" & Me.tb_Other1 & _
" Where" & [Tbl_Section_1]![UniqueID] = Me.Tb_UniqueId
End If

When run a run time error 2465 is returned. I think it is to do with the Where clause of the statement.
 
Yes, you probably need a space after the WHERE clause; otherwise, your query would be something like WHERE## without the space between the word WHERE and your [Tbl_Section_1]![UniqueID]

Code:
"UPDATE Tbl_Section_1 SET Tbl_Section_1.ProgUsed = " & Me.Lb_Programmes.ItemData(varItm) & _
" WHERE " & [Tbl_Section_1]![UniqueID]  & " = "  & Me.Tb_UniqueId
 
Last edited:
I have changed the where clause to:

"' WHERE Tbl_Section_1.UniqueID = '" & Me.Tb_UniqueId & "'"

and it works fine.

Thanks

C
 

Users who are viewing this thread

Back
Top Bottom