Avatar of eyes59
eyes59

asked on 

sql syntax error in VBA code of ACCESS 2003

I get a syntax error when I try to run the following code.
'Validation message if needed
    If validationError Then
        MsgBox validationMessage, vbOKOnly, "Validation Error"
        Exit Sub
    Else
        valErrSource = cmbxErrSource.Value
        valIssueDt = txtIssueDate.Value
        valContractNo = txtContractNo.Value
        valErrDate = txtErrDate.Value
        valInformedVia = cmbxInformVia.Value
        valWorkType = cmbxWorkType.Value
        
    End If
    
    'Set Defaults
      'request status set above
    
    'Insert the Error Source header
    sql = "Insert Into tblData " & _
    " (cmbxErrSource, txtIssueDate, txtContractNo, txtErrDate, cmbxInformVia, cmbxWorktype) " & _
    "SELECT '" & cmbxErrSource & "'" & _
    ", " & txtIssueDate & _
    ", " & txtContractNo & _
    ", " & txtErrDate & _
    ", " & cmbxInformVia & _
    ", '" & cmbxWorkType & "'"
    db.Execute (sql)
 
       
    'Get the requestId
    sql = "Select max() as NewId from tblData"
    Set rs = db.OpenRecordset(sql)
    requestID = rs!NewId
    rs.Close

Open in new window

Microsoft AccessMicrosoft ApplicationsSQL

Avatar of undefined
Last Comment
Rey Obrero (Capricorn1)

8/22/2022 - Mon