Results 1 to 3 of 3
  1. #1
    avitale is offline Novice
    Windows Vista Access 2010 32bit
    Join Date
    May 2012
    Posts
    1

    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
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    First, that isn't a macro, it is VBA coding. Macros and VBA are two different means of coding within Access.

    Not sure what that error number means but the unnecessary final comma at the end of the sql string is definitely a syntax error.

    Why are you using INSERT anyway? I hope you aren't duplicating data. Are you not using bound forms?

    Also, it is not necessary to type the .Value as it is the default for data controls and will be assumed if no property referenced.
    Last edited by June7; 05-20-2012 at 11:51 PM.
    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
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    This should help you debug it:

    http://www.baldyweb.com/ImmediateWindow.htm

    You actually have two of the commas mentioned by June7. Further, only text values should be surrounded by the single quotes. Date values by #, numeric values by neither (determined by the data type of the target fields).
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Replies: 5
    Last Post: 03-27-2012, 01:40 PM
  2. Run Time Error '94'
    By dongodu in forum Programming
    Replies: 14
    Last Post: 10-23-2011, 08:08 AM
  3. Replies: 2
    Last Post: 12-23-2010, 09:11 AM
  4. Replies: 2
    Last Post: 12-02-2010, 02:35 AM
  5. Run time error
    By vaikz in forum Import/Export Data
    Replies: 1
    Last Post: 02-18-2010, 11:37 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