+ Reply to Thread
Results 1 to 3 of 3

Query Access Database in Excel

  1. #1
    Registered User
    Join Date
    05-10-2007
    Posts
    16

    Query Access Database in Excel

    I have a spreadsheet with multiple queries from a single database “DB1”. I have a second database “DB2” with the same tables as DB1 and would like to change all of my queries to run from DB2 instead of DB1. Is there an easy way to do that?


    Thanks!

  2. #2
    Valued Forum Contributor Richard Schollar's Avatar
    Join Date
    05-23-2006
    Location
    Hampshire UK
    MS-Off Ver
    Excel 2002
    Posts
    1,264
    Hi

    Yes - you need to get the current connection string you are using for your current database. Easiest way to do this is to (whilst this spreadsheet is active in Excel) open up the VBE with Alt+F11, open up the Immediate Window with Ctrl+G and type in:

    Please Login or Register  to view this content.
    and press return at the end of the line.

    This will give you a string similar to the following:

    Please Login or Register  to view this content.
    obviously with different paths/folders. It's the bit in red that you will need to change to the new database location. You can do this for all the QTs by running the following code script in this workbook:

    Please Login or Register  to view this content.
    replacing the bit in red with your new database name and file path (this connection string must in all respects be identical to the one you got in the Immediate Window, just the new file name and path should be different).

    Make sense?

    Richard

  3. #3
    Registered User
    Join Date
    05-10-2007
    Posts
    16
    It worked!

    Thanks Much!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Excel query and parameters
    By urbanmojo in forum Excel General
    Replies: 1
    Last Post: 07-23-2007, 12:17 AM
  2. Fire Access Make-Table Query from Excel
    By afiack in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-11-2007, 07:43 PM
  3. Automating an MS Access to Excel query
    By rla201 in forum Excel General
    Replies: 1
    Last Post: 01-30-2007, 06:27 PM
  4. Creating a database in excel
    By Michelle_Man in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-30-2006, 10:59 PM
  5. How to populate excel combo box with access database?
    By computerguy in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-04-2006, 11:05 PM

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