update data on sql table using vba (1 Viewer)

cosminb2019

New member
Local time
Today, 14:17
Joined
Mar 22, 2019
Messages
1
Hi,

I'm trying to update my data based on the form using the sql query

My sql query is
CurrentDb.Execute "UPDATE dbo_Suppliers SET AccountCode='" & Me.txtAccountCode & ",Company='" & Me.txtCompany & "',ContactPerson1='" & Me.txtContactPerson1 & "',PhoneNumber1='" & Me.txtPhoneNumber1 & "',Ext1='" & Me.txtExt1 & "',Email1='" & Me.txtEmail1 & "',Note1='" & Me.txtNote1 & "',ContactPerson2='" & Me.txtContactPerson2 & "',PhoneNumber2='" & Me.txtPhoneNumber2 & "',Ext2='" & Me.txtExt2 & "',Email2='" & Me.txtEmail2 & "',Note2='" & Me.txtNote2 & "',ContactPerson3='" & Me.txtContactPerson3 & "',PhoneNumber3='" & Me.txtPhoneNumber3 & "',Ext3='" & Me.txtExt3 & "',Email3='" & Me.txtEmail3 & "',Note3='" & Me.txtNote3 & "' WHERE AccountCode="


The error I'm receiving is 3075

Syntax error (missing operator) in the query expression

I had a look I have searched I just cannot figure this out.

Anyone can help, please?

Thank you.
 

plog

Banishment Pending
Local time
Today, 16:17
Joined
May 11, 2011
Messages
11,638
You have 36 double quotes in that thing. You have 33 single quotes. Somebody is missing a partner.

Further, why isn't your WHERE clause finished?
 

Minty

AWF VIP
Local time
Today, 22:17
Joined
Jul 26, 2013
Messages
10,368
To assist you with the dating game Plog so eloquently pointed out - try making your sql statement a string first, and have a look a at what you get;

Code:
Dim sSql as String

sSql = "UPDATE dbo_Suppliers SET AccountCode='" & Me.txtAccountCode & ",Company='" & Me.txtCompany & "',ContactPerson1='" & Me.txtContactPerson1 & "',PhoneNumber1='" & Me.txtPhoneNumber1 & "',Ext1='" & Me.txtExt1 & "',Email1='" & Me.txtEmail1 & "',Note1='" & Me.txtNote1 & "',ContactPerson2='" & Me.txtContactPerson2 & "',PhoneNumber2='" & Me.txtPhoneNumber2 & "',Ext2='" & Me.txtExt2 & "',Email2='" & Me.txtEmail2 & "',Note2='" & Me.txtNote2 & "',ContactPerson3='" & Me.txtContactPerson3 & "',PhoneNumber3='" & Me.txtPhoneNumber3 & "',Ext3='" & Me.txtExt3 & "',Email3='" & Me.txtEmail3 & "',Note3='" & Me.txtNote3 & "' WHERE AccountCode="

Debug.Print sSql   [COLOR="SeaGreen"] ' Press Ctrl + G in the VBA editior to see this[/COLOR]

CurrentDb.Execute sSql
 

Users who are viewing this thread

Top Bottom