+ Reply to Thread
Results 1 to 4 of 4

Thread: Excel SQL code

  1. #1
    Registered User
    Join Date
    09-23-2010
    Location
    London, England
    MS-Off Ver
    2007
    Posts
    97

    Excel SQL code

    Hi, i'm trying to pass SQL code to an access db, the access db has the multiple entry in a single collum option active, i.e. country (France, Uk, Ireland) rather than using relations ect... my question is how do i pass sql code to record data into it

    my code

    rst.Open "Select * From Feed", conn
        Sheets("Feeds").Range("A2").CopyFromRecordset rst
    happily grabs the data, but then wont let me re enter it... really anoying
    my code to re enter is

     vtSql = ""
        vtSql = vtSql & " INSERT INTO Feeds (ID, Start Date, Stop Date, Languages, Countries, Advertising, Region, Transmission Costs)"
        vtSql = vtSql & " VALUES (" & R & ", " & Range("B" & R).Value & ", " & Range("C" & R).Value & ", " & Range("D" & R).Value & ", " & Range("E" & R).Value & ", " & Range("F" & R).Value & ", " & Range("G" & R).Value & ", " & Range("H" & R).Value & ", " & Range("I" & R).Value & ")"
        conn.Execute vtSql

    any suggestions?
    Last edited by Jollyfrog; 09-28-2010 at 10:41 AM. Reason: code update

  2. #2
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    Apparently I can't say
    MS-Off Ver
    Apparently I can't say
    Posts
    8,274

    Re: Excel SQL code

    If your field names contain spaces, you should include them in square brackets. You also need to enclose any text data you are passing in single quotes.

  3. #3
    Registered User
    Join Date
    09-23-2010
    Location
    London, England
    MS-Off Ver
    2007
    Posts
    97

    Re: Excel SQL code

    Ah thanks, i now get INSTERT ITNO query cannot contain multi valued field

    how do i get round this?

    thanks

    Jonathan

  4. #4
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    Apparently I can't say
    MS-Off Ver
    Apparently I can't say
    Posts
    8,274

    Re: Excel SQL code

    I don't know offhand. Multi-value fields pretty much violate every database principle, so I never use them.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.2.0