Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2015
    Posts
    3

    Unanswered: Run-time error '3134': syntax error into INSERT STATEMENT

    Greetings,

    So I'm trying a few things with access and right now im getting an error on this code:

    Private Sub cmdKijkFilm_Click()
    Dim strSQL As String
    strSQL = "INSERT INTO dbo_watchhistory (movie_id, customer_mail_adress, watch_date, price, invoiced)" _
    & "VALUES (" & Me.txtmovieid & ", " ' & Me.txtMail & '", #" & Me.txtDate & "#, " & Me.txtprice & ", '0');"
    DoCmd.RunSQL strSQL
    End Sub

    I can't really figure out what the problem is. The error im getting is:

    Run-time error '3134':
    syntax error into INSERT STATEMENT

    Any ideas?

  2. #2
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    Try (notice the space at the end of the first line):
    Code:
    strSQL = "INSERT INTO dbo_watchhistory (movie_id, customer_mail_adress, watch_date, price, invoiced) " _
    & "VALUES (" & Me.txtmovieid & ", " ' & Me.txtMail & '", #" & Me.txtDate & "#, " & Me.txtprice & ", '0');"
    Have a nice day!

  3. #3
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    |Im sure sinndho has got it right
    but the easy way to resolve this issues is to actuallyu look at the value of the variable strSQL NOT the VBA that create the SQL
    so set a break point (ie use the debugger, if you dont' knwo how to tuse the debugger [or worse yet dont' know what the debugger is / does] then know whould be a good time to learn) or at the very least display the value of strSQL in a message box)

    check the pairings of ' around text literals.

    Im suspicious of

    Code:
    ", " ' & Me.txtMail & '", #" & Me.txtDate & "#, " & Me.txtprice & ", '0');"
    I'd rather be riding on the Tiger 800 or the Norton

Tags for this Thread

Posting Permissions

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