Sql Server 2008 R2 back end connected via ODBC, Access 2007 front end, All tables are linked and show up in the Tables view, SA authority, Database is in development not production.
I am writing a SQL Update query in VBA that executes on the AfterUpdate Event Procedure of a combo box. All of the Variables populate with the correct data. My SQL statement runs fine except the WHERE clause prompts me to enter the AttachID. It should get it from the variable IntAttach but it's not. As soon as I enter the AttachID = 9 in the prompt box, everything executes perfectly. I don't understand what is wrong with my WHERE statement. I am attempting to update the Access linked table dbo_PropertyEntity.
Code:
Private Sub PickNewEntity_AfterUpdate()
Dim IntAttach As Integer
Dim IntEnity As Integer
Dim strName As String
Dim strAddress As String
IntAttach = Forms!Property!PropertyEntityJoin_SubFrm!AttachedID
IntEntity = Forms!Property!PropertyEntityJoin_SubFrm!PickNewEntity.Column(2)
strName = Forms!Property!PropertyEntityJoin_SubFrm!PickNewEntity.Column(0)
strAddress = Forms!Property!PropertyEntityJoin_SubFrm!PickNewEntity.Column(1)
stSQL = "UPDATE DBO_PropertyEntity" & " SET EntityID = EntityName = '" & strName & "', EntityAddress = '" & strAddress & "'" & " WHERE AttachID = " & IntAttach & ";"
DoCmd.RunSQL stSQL
Me.Requery
End Sub
Any suggestions?
Thanks Phred