insert into sql statement not working why?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • JonHuff
    New Member
    • Sep 2010
    • 14

    #1

    insert into sql statement not working why?

    here is my code - whats wrong?

    Code:
    DoCmd.SetWarnings False
    
    sSQL = "INSERT INTO tbl_temp " & _
    " ([WhoFrom]) VALUES ('" & x & "');"
    
    DoCmd.RunSQL (sSQL)
    DoCmd.SetWarnings True
    error i get is #3075 - "syntax error - missing operator in query expression"

    i have

    Code:
    DIM sSQL as String
    DIM x as String
    in tbl_temp field WhoFrom is text
    Last edited by NeoPa; Dec 13 '10, 04:14 PM. Reason: Added CODE tags
  • gershwyn
    New Member
    • Feb 2010
    • 122

    #2
    I see nothing wrong with your SQL as is.

    Are you getting that error on the DoCmd.RunSQL line, or might it be elsewhere in your code?

    It might also be a good idea to add
    Code:
    Debug.Print sSQL
    before you execute it, to be absolutely sure what the program is seeing is what you expect it to be seeing.

    Edit: What value are you using for X? There wouldn't happen to be an apostrophe or something similar, would there?

    Comment

    Working...