Results 1 to 6 of 6
  1. #1
    Eranka is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Dec 2017
    Posts
    150

    Syntax Error In Insert Into

    HI

    Code:
     CurrentDb.Execute "INSERT INTO Repair (Title,Customer_Name,Mobile_Number,Land_Number,Email,ID_No,Job_No,Collected_Date,Manufacturer,Other_Manufacturer,Model,Other_Model,Serial_Number,Warranty,Purchased_Date,Repair_Type,Status,Remarks)" & "VALUES ('" & Me.Combo41 & "','" & Me.Text5 & "','" & Me.Text77 & "','" & Me.Text59 & "','" & Me.Text8 & "','" & Me.Text9 & "'," & Me.Text15 & ",'" & Me.Text72 & "','" & Me.Combo63 & "','" & Me.Text16 & "','" & Me.Text17 & "','" & Me.Text65 & "','" & Me.Text67 & "','" & Me.Combo43 & "','" & Me.Text73 & "','" & Me.Text19 & "','" & Me.Combo75 & "','" & Me.Text55 & "')"
    Hi when i execute the above code i get Syntax Error In Insert Into Statement.

    Please help

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,816
    Are these fields all text type? Missing apostrophe delimiters for Text15.

    Line continuation can make easier to read.
    Code:
    CurrentDb.Execute "INSERT INTO Repair (Title, Customer_Name, Mobile_Number, Land_Number, Email, ID_No, Job_No, Collected_Date, " & _
         "Manufacturer, Other_Manufacturer, Model, Other_Model, Serial_Number, Warranty, Purchased_Date, Repair_Type, Status, Remarks)" & _
         "VALUES ('" & Me.Combo41 & "','" & Me.Text5 & "','" & Me.Text77 & "','" & Me.Text59 & "','" & Me.Text8 & "','" & Me.Text9 & "'," & _
         Me.Text15 & ",'" & Me.Text72 & "','" & Me.Combo63 & "','" & Me.Text16 & "','" & Me.Text17 & "','" & Me.Text65 & "','" & Me.Text67 & "','" & _
         Me.Combo43 & "','" & Me.Text73 & "','" & Me.Text19 & "','" & Me.Combo75 & "','" & Me.Text55 & "')"
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,397
    also think this

    & Me.Text55 & "')"

    should be


    & Me.Text55 & "'")

    Always better to assign your sql to a sql string so you can debug it before executing it.

    dim sqlStr as String
    sqlStr="INSERT INTO.....
    debug.print sqlStr
    Currentdb.execute (sqlStr)

    and giving your control names relevant names helps considerably

  4. #4
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,388
    Missing space:
    Code:
    ,Status,Remark)" & "VALUES ('" & Me.Combo41 & "','

    use this:
    Code:
    ,Status,Remarks) VALUES ('" & Me.Combo41 & "','
    or this:
    Code:
    ,Status,Remarks)" & " VALUES ('" & Me.Combo41 & "','
    Last edited by davegri; 11-04-2019 at 10:00 AM. Reason: layout

  5. #5
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,816
    @Ajax, parenthesis is correct in original - it is closing paren for VALUES clause.

    @davegri, additional space won't make a difference - query will recognize VALUES clause without.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  6. #6
    Eranka is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Dec 2017
    Posts
    150
    Thanks alot guys for the help, It Worked

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 4
    Last Post: 03-26-2019, 02:40 PM
  2. Syntax Error In Insert Into Statement
    By Eranka in forum Access
    Replies: 7
    Last Post: 06-02-2018, 03:48 AM
  3. syntax error in insert into
    By rameshjctr in forum Forms
    Replies: 5
    Last Post: 02-05-2016, 05:41 AM
  4. Replies: 3
    Last Post: 03-05-2013, 11:17 AM
  5. INSERT INTO Syntax Error
    By eww in forum Programming
    Replies: 1
    Last Post: 04-06-2011, 10:28 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums