Results 1 to 4 of 4
  1. #1
    opopanax666 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2010
    Posts
    27

    Error 3146 in Access 2007, not in Access 2010

    Hello everyone,



    Following piece of code gives me no trouble in A2010, but gives an error 3146 in A2007, so probably a syntax problem, but I can't see anything wrong:
    Code:
    strSQL = "INSERT INTO dbo_tblGEPRODUCEERD ([Geprod_ID], [Barcode], [Weging_datum], [Product_id], [Bestemming_id], [Gewicht_bruto], [Gewicht_tarra], [Gewicht_netto], [Geprod_status_id]) VALUES (" & lngNewGeprod_ID & ", '" & "*" & strCODE & "*" & "', " & SQLDate(varDATUM) & ", " & intPRODUCT & ", " & intBESTEMMING & ", " & sinBRUTO & ", " & sinTARRA_TOTAAL & ", " & sinNETTO & ", 1)"
    Set db = CurrentDb()
    db.Execute strSQL, dbFailOnError
    Set db = Nothing
    Geprod_ID: integer (= lngNewGeprod_ID)
    Barcode: string (= "*" & strCODE & "*")
    Weging_datum: date (= SQLDate(varDATUM))
    Product_id: integer (= intPRODUCT)
    Bestemming_id: integer (= intBESTEMMING)
    Gewicht_bruto: single (= sinBRUTO)
    Gewicht_tarra: single (= sinTARRA_TOTAAL)
    Gewicht_netto: single (= sinNETTO)
    Geprod_status_id: integer (= 1)

    The "SQLDate(varDATUM)" is the Allen Brown function found here. It results in a "date-string" (i.e. "#dd/mm/yyyy hh:mm:ss#"). After getting the 3146, I tried handling this as a string, so putting it beween quotation marks, but that gave a 3464 error, so that wasn't the problem.

    I can't see anything wrong with the rest, so is there something different between 2007 & 2010 that I'm not aware of?

  2. #2
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    First, what is the text of the error? Second, this technique will help make sure the SQL is coming out correctly.

    http://www.baldyweb.com/ImmediateWindow.htm
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    opopanax666 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2010
    Posts
    27
    Quote Originally Posted by pbaldy View Post
    First, what is the text of the error? Second, this technique will help make sure the SQL is coming out correctly.

    http://www.baldyweb.com/ImmediateWindow.htm
    Found it! First changed everything to recordsets (which I wanted to do anyway), but got the same error.
    Then used the procedure found here to get some better info.
    Gave me an "error 544 - cannot insert explicit value for identity column when identity_insert is set to OFF", which reminded me of the fact I inserted a value in a SQL autonumber field (which I intended to change, but forgot about ).

    So, changed that, and everything works now!..

  4. #4
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Glad you got it sorted.
    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: 01-07-2016, 12:49 PM
  2. Replies: 0
    Last Post: 07-31-2012, 12:25 PM
  3. Replies: 1
    Last Post: 06-21-2012, 07:58 PM
  4. Replies: 3
    Last Post: 05-30-2012, 01:43 PM
  5. ODBC Error 3146 on rs.update
    By sharon.chapman7 in forum Programming
    Replies: 6
    Last Post: 03-06-2012, 08:45 AM

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