Closed Thread
Results 1 to 2 of 2

insert into syntax error, sql not executing

Hybrid View

  1. #1
    Registered User
    Join Date
    07-04-2012
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    38

    insert into syntax error, sql not executing

    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.

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: insert into syntax error, sql not executing

    Duplicate post. Please don't do that.
    Entia non sunt multiplicanda sine necessitate

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1