Help for Insert command

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • eacollie
    New Member
    • Feb 2008
    • 14

    #1

    Help for Insert command

    The following code
    Code:
    strSQL = "INSERT INTO srkData ( TransactionDate, Dow, NAS, SPY, DN Issues, UP Issues, Highs, Lows, Nat Gas, Oil, Gold, Dollar, Silver, Vol ) " & _
    "SELECT #" & CDate(Me.OpenArgs) & "# AS TransactionDate, Dow, NAS, SPY, DN Issues, Highs, Lows, Nat Gas, Oil, Gold, Dollar, Silver, Vol"
    
    DoCmd.RunSQL strSQL
    gives me "syntax error in insert statement".

    I have an ID field set to autonumber.

    What am I doing wrong?

    thanks!
  • yarbrough40
    Contributor
    • Jun 2009
    • 320

    #2
    when you have column names with spaces you must bracket them --> [DN Issues], [UP Issues],[Nat Gas],

    Comment

    • eacollie
      New Member
      • Feb 2008
      • 14

      #3
      Thanks yarbrough40,
      I made the changes and now get an error:

      Syntax error in query expression 'SELECT #8/20/2010# As TransactionDate '

      How should I be formatting the date to insert into the date field?

      thanks!

      Comment

      • yarbrough40
        Contributor
        • Jun 2009
        • 320

        #4
        remove "as TransactionDate " in your select clause. You don't need to define column headers.
        Code:
        "SELECT #" & CDate(Me.OpenArgs) & "#, Dow, NAS
        ....

        Comment

        Working...