Hello All,
I have created a userform where the data needs to store in access db automatically,
However i m getting a syntax error at INSERT INTO statement,yellow coloured at .execute stSQL tried in google to solve the error, but seems no assistance.
Here is my code:
Public Sub Save_Click()
'Initialize all variables
Dim Cn As New ADODB.Connection
Dim Rs As New ADODB.recordSet
Dim stDB As String, stSQL As String, stProvider As String
stDB = "Data Source= E:\SAMI.accdb"
stProvider = "Microsoft.ACE.OLEDB.12.0"
With Cn
' Opening connection to database
.ConnectionString = stDB
.Provider = stProvider
.Open
'SQL Statement of what I want from the database
stSQL = "INSERT INTO SAMI_Data (CSTName, EmailSub,) " & _
"Values ('" & SAMI_Tracking.Cst_Nme.Value & "', '" & SAMI_Tracking.Email_Sub.Value & "',')"
.Execute(stSQL)
End With
Set Rs = Nothing
Set Cn = Nothing
End Sub
It would be really appreciable if any 1 can really help me on the same.
Many thanks in advance to all.
Bookmarks