Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2009
    Posts
    1

    Unanswered: Runtime Error 3134 - Insert Into Syntax Error

    Hi, im trying to append a record to a table called "SERVER" using the following code.


    ************************************************** *******
    Dim sql
    Dim year
    Dim gp
    Dim dates
    Dim datename
    year = Me.Year_Textbox
    gp = Me.GP_Code_Textbox
    datest = CStr(Me.YearStart)
    datename = "date 1"

    sql = "INSERT INTO SERVER (Year, GPCode, BoxID, Value) VALUES ( '" & year & "' , '" & gp & "' , '" & datename & "' , '" & datest & "' )"
    MsgBox sql
    DoCmd.RunSQL sql


    ************************************************** *******


    my problem is that it keeps returning a RUNTIME ERROR 3134 INSERT INTO SYNTAX ERROR.

    I cant for the life of me figure this out. can anyone help please?

  2. #2
    Join Date
    Sep 2006
    Location
    Surrey, UK
    Posts
    994
    Provided Answers: 2
    "Year" and (I think) "Value" are reserved words in Jet SQL, and should not be used for field names. To get around this, surround them with square brackets ("[Year]", "[Value]").
    Also, what data type are the fields? Your SQL statement is treating every value as text, which will cause problems if the fields are set to other types.

  3. #3
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    reserved words don't helpthings

    what does the message box say, does the SQL its displaying look valid

    it could be duff data
    I'd rather be riding on the Tiger 800 or the Norton

Posting Permissions

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