Results 1 to 8 of 8
  1. #1
    HS_1 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2016
    Posts
    109

    code fails (syntax error)

    Can anyone tell me why the following code fails to execute when I am trying to input values into table, I am getting syntax error?
    Thanks

    Private Sub cmdPercentComplete_CWP_Click()
    Dim rsSQL As DAO.Recordset


    Dim rsEHTStageTally As DAO.Recordset
    Dim rsEHTStagePercent As DAO.Recordset
    Dim rsTotals As DAO.Recordset
    Dim strsql As String


    Dim intTemp, X As Integer
    Dim intEHTStageTally As Integer
    Dim intEHTStagePercent As Integer
    Dim intTotals As Integer


    Dim dblPercentComplete As Double


    strsql = "INSERT INTO tblCWP_PercentComplete (EHT_EWP, "Total, Confirmed, Assembled, Reset, ReDesignRequired, DesignComplete, 3DCaddComplete, " & _
    "ReCaddRequired, 2DCaddComplete, QCReviewComplete, CheckingComplete, IFCPending, IFC, PercentComplete) " & _
    "SELECT '" & rsEHTStageTally.Fields("EHT_EWP") & "', " & rsEHTStageTally.Fields("Total") & ", " & _
    rsEHTStageTally.Fields("Assembled") & ", " & rsEHTStageTally.Fields("Reset") & ", " & _
    rsEHTStageTally.Fields("ReDesignRequired") & ", " & rsEHTStageTally.Fields("DesignComplete") & ", " & _
    rsEHTStageTally.Fields("3DCaddComplete") & ", " & rsEHTStageTally.Fields("ReCaddRequired") & ", " & _
    rsEHTStageTally.Fields("2DCaddComplete") & ", " & rsEHTStageTally.Fields("QCReviewComplete") & ", " & _
    rsEHTStageTally.Fields("CheckingComplete") & ", " & rsEHTStageTally.Fields("IFCPending") & ", " & _
    rsEHTStageTally.Fields("IFC") & ", " & Format(dblPercentComplete, "0.00") & ";"
    Debug.Print strsql
    CurrentDb.Execute strsql

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    Can't you tell us WHERE the error is?

  3. #3
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    Do all your string fields have delimiters?

  4. #4
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    since you debug.print the sql - can you post the resultant sql here

    Also to echo Ranman's comment - can you tell us WHERE the Selected data is coming FROM?

  5. #5
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Code:
    strsql = "INSERT INTO tblCWP_PercentComplete (EHT_EWP, "Total,  Confirmed, Assembled, Reset, ReDesignRequired, DesignComplete,  3DCaddComplete, " & _
    Is there a reason you have a double quote in the 2nd field ("Total")???
    Remove it and the error seems to go away........ don't know if it will execute properly, though.

  6. #6
    Micron is offline Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,803
    I don't use line continuation characters, so correct me if I'm wrong, but I don't believe you should be using double quotes at the breakpoint of the line, unless it's to do something like concatenate single quotes around control names with text values. So why 3DCaddComplete, " & _ as opposed to 3DCaddComplete, & _ ?
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  7. #7
    HS_1 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2016
    Posts
    109
    Thanks guys for your help it was double quote as ssanfu pointed out.

  8. #8
    HS_1 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2016
    Posts
    109

    Thanks guys for your help

    It was a double quote as ssunfu pointed out.
    HS_1

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

Similar Threads

  1. Syntax error in Keyword Search code
    By bsegge in forum Programming
    Replies: 10
    Last Post: 10-03-2016, 12:40 PM
  2. Replies: 3
    Last Post: 02-13-2015, 10:18 AM
  3. Replies: 5
    Last Post: 06-26-2014, 12:52 PM
  4. Syntax Error in my Query Code
    By PPat in forum Queries
    Replies: 5
    Last Post: 04-19-2013, 03:12 PM
  5. Code works in full, fails in Runtime
    By stephenaa5 in forum Programming
    Replies: 3
    Last Post: 09-14-2010, 12:30 PM

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