Results 1 to 4 of 4

Excel -> Access Importing Connection Error - Invalid SQL statement; expected 'DEL....

Threaded View

scottr1 Excel -> Access Importing... 12-23-2011, 05:37 PM
scottr1 Re: Excel -> Access Importing... 12-27-2011, 05:02 PM
OnErrorGoto0 Re: Excel -> Access Importing... 01-04-2012, 02:52 AM
OnErrorGoto0 Re: Excel -> Access Importing... 01-04-2012, 09:27 AM
  1. #1
    Registered User
    Join Date
    12-22-2011
    Location
    Miami
    MS-Off Ver
    Excel 2010
    Posts
    3

    Excel -> Access Importing Connection Error - Invalid SQL statement; expected 'DEL....

    Hello-

    I've recently upgraded to Excel 2010 and my firm has decided not to purchase Access with the 2010 Office suite. Because of this I need a new connection method to an Access database (from xls) that doesn't require the user to have Access 2010 on their machine. I'm now trying to tweak my access importing function to use an ADODB connection and I'm getting the error above. If anyone has any sample code that achieves an import of an xls spreadsheet into an Access table from xls 2010 it would be my Christmas miracle. Here's the function I'm working with. I've taken numerous stabs in the dark so I apologize if it's not even close to what I ultimately need to make this happen.

    I have one line of code commented out below, when I switch back and forth I do get a different error. Not sure which one is closer to achieving the import.

    Public Function ImportXlsFileNew(ByVal dbFilePath As String, ByVal dbFileName As String, ByVal dbTableName As String, ByVal xlsFilePath As String, ByVal xlsFileName As String)
        Dim cnt As ADODB.Connection
        Dim stSQL As String, stCon As String
        Dim stSQL2 As String
         
        'stCon = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & dbFilePath & dbFileName & ";Extended Properties=""Excel 12.0 Xml;HDR=YES"";"
         stCon = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & dbFilePath & dbFileName & ";"
        
     ' SQL code for Insert to Access    
        stSQL = "'INSERT INTO' '" & dbTableName & "' " & """" & "SELECT * FROM [UploadData$] IN " & xlsFilePath & "\" & xlsFileName & """"
            
          'set connection  variable
        Set cnt = New ADODB.Connection
         'open connection to Access db and run the SQL
        With cnt
            .Provider = "Microsoft.ACE.OLEDB.12.0;Data"
            .Open stCon
            .CursorLocation = adUseClient
            .Execute (stSQL)
        End With
         'close connection
        cnt.Close
         
         'release object from memory
        Set cnt = Nothing
    End Function
    Any assistance is appreciated.

    Thanks,
    Last edited by scottr1; 12-27-2011 at 05:05 PM.

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.6.0 RC 1