1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Pull data from ACCDB into Excel..simple?

Discussion in 'Business Applications' started by chaostheory, Jun 13, 2011.

Thread Status:
Not open for further replies.
Advertisement
  1. chaostheory

    chaostheory Thread Starter

    Joined:
    May 18, 2007
    Messages:
    114
    I swear this worked when i started this project. Can anyone spot what is wrong with this that it would generate a "general ODBC error"

    Code:
    Sub Checker()
    
    Dim varConn As String, varSQL As String
    
    varConn = "ODBC;DBQ=WORK ORDERS 2010_1.accdb;Driver={Driver do Microsoft Access (*.accdb)}"
    
    varSQL = "SELECT * FROM TALISMAN"
    'MsgBox varSQL
    With ActiveSheet.QueryTables.Add(Connection:=varConn, Destination:=Range("A1"))
        .CommandText = varSQL
        .Name = "Query-39008"
        .FieldNames = False
        .RowNumbers = False
        .FillAdjacentFormulas = False
        .PreserveFormatting = True
        .RefreshOnFileOpen = False
        .BackgroundQuery = True
        .RefreshStyle = xlOverwriteCells
        .SavePassword = False
        .SaveData = True
        .AdjustColumnWidth = False
        .RefreshPeriod = 0
        .PreserveColumnInfo = True
        .Refresh BackgroundQuery:=False
    End With
    
    End Sub
    
     
  2. Rockn

    Rockn

    Joined:
    Jul 29, 2001
    Messages:
    21,334
    Spaces in your database file name perhaps?
     
  3. chaostheory

    chaostheory Thread Starter

    Joined:
    May 18, 2007
    Messages:
    114
    I dont think so...the spaces are in the filename. I have some scripts where i used this code before on a thumb drive i will check it out here in a bit. Gotta be missing something simple because i swear i had even pulled this before i had got put onto a different project after starting this one.
     
  4. Rockn

    Rockn

    Joined:
    Jul 29, 2001
    Messages:
    21,334
    Can you debug it by putting a break point in your code? Does the driver also exist in your ODBC driver collection?

    I really think there are issues with spaces in path to a database.

    Driver={Microsoft Access Driver (*.mdb, *.accdb)};Dbq=C:\mydatabase.accdb

    Try taking out the ODBC
     
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/1002045

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice