Results 1 to 2 of 2
  1. #1
    Join Date
    May 2012
    Posts
    1

    Unanswered: Run-time Error '3134'

    Hey everybody,
    I am new to Access (using it in a class) and have been experiencing Run-time error '3134' while trying to create a macro. It says "Syntax error in INSERT INTO statement" and highlights the line "CurrentDb.Execute ClientSQL"

    Private Sub Intake_DblClick(Cancel As Integer)

    If Me.Confidentiality_Explained_Date.Value = False Then
    MsgBox "Confidentiality Form must be explained before Intake"
    ElseIf IsNull(Me.Case_Number.Value) Or Trim(Me.Case_Number.Value) = "" Then
    MsgBox "Case number is not optional"
    Else
    Dim ClientSQL As String
    ClientSQL = "INSERT INTO [Client] (" & _
    "[First Name], " & _
    "[Middle Initial], " & _
    "[Last Name], " & _
    "[Home Telephone No] " & _
    ") VALUES (" & _
    "'" & Me.First_Name.Value & "', " & _
    "'" & Me.Middle_Initial.Value & "', " & _
    "'" & Me.Last_Name.Value & "', " & _
    "'" & Me.Home_Telephone_No.Value & "', " & _
    ")"

    CurrentDb.Execute ClientSQL

    Dim CaseSQL As String
    CaseSQL = "INSERT INTO [Case] (" & _
    "[Case Number], " & _
    "[Caller and Client Relationship], " & _
    "[Caller Name], " & _
    "[Caller's Home Phone No], " & _
    "[Confidentiality Explained Date], " & _
    "[Alternatives Pursued], " & _
    "[Referral Source Code], " & _
    "[Confidentiality Form Sent Method], " & _
    "[Confidentiality Form Sent], " & _
    "[Confidentiality Form Received], " & _
    ") VALUES (" & _
    "'" & Me.Case_Number.Value & "', " & _
    "'" & Me.Caller_and_Client_Relationship.Value & "', " & _
    "'" & Me.Caller_Name.Value & "', " & _
    "'" & Me.Caller_s_Home_Phone_No.Value & "', " & _
    "'" & Me.Confidentiality_Explained_Date.Value & "', " & _
    "'" & Me.Alternatives_Pursued.Value & "', " & _
    "'" & Me.Referral_Source_Code.Value & "', " & _
    "'" & Me.Confidentiality_Form_Sent_Method.Value & "', " & _
    "'" & Me.Confidentiality_Form_Sent.Value & "', " & _
    "'" & Me.Confidentiality_Form_Received.Value & "', " & _
    ")"



    CurrentDb.Execute CaseSQL

    CurrentDb.Execute "DELETE FROM [Potential Clients] WHERE [Work Request Number] = " & Me.Work_Request_Number.Value

    MsgBox "Client intake successful, record removed from work request"

    End If


    End Sub

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    you have a dangling comma here --

    "'" & Me.Home_Telephone_No.Value & "', " & _


    you'll find a similar problem in CaseSQL
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

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