+ Reply to Thread
Results 1 to 4 of 4

Possible to access... Access database table if file name changes (fixed prefix)?

  1. #1
    Registered User
    Join Date
    05-08-2017
    Location
    Toronto
    MS-Off Ver
    2016
    Posts
    81

    Possible to access... Access database table if file name changes (fixed prefix)?

    Hi all,

    I tried looking online but couldn't find anything on this. Basically, I have an Excel spreadsheet where I pulled data from an Access database using the "From Access" button and following the instructions. The database was imported successfully, I added the macros that were needed in the spreadsheet, and making changes in the .accdb data and refreshing works fine too. H

    However, it seems the accdb file's name is supposed to change, which means connectivity cannot be maintained. The accdb file's name format is simply "Stuff Access Database [Month] [Day]", for example "Stuff Access Database March 23". Is there a way to maintain the connectivity by, say, checking only if the file has "Stuff Access Database" as a prefix, rather than the whole name? No other file in the directory has this same prefix. I understand this is a long shot, but thought I'd try asking any way.

    Thanks!
    Last edited by noname91; 04-08-2020 at 05:28 PM.

  2. #2
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Possible to access... Access database table if file name changes (fixed prefix)?

    There is a way. It involves using MS-Query (More primitive, but can be manipulated more easily) and then changing the connection string.

    To get to Ms-Query select Data -> Get Data -> From other sources -> From Microsoft Query.

    As soon as the dialog box comes up, check off the box that asks you to use the wizard. The wizard is more of a hindrance than a help.

    MS-Access is one of the data sources set up. Select it and navigate to the directory and database you want. Then select the table or query you want and you will get an Access-like user interface where you can drag and drop the fields where you want them. I suggest creating a query in Access that does what you want. However, do NOT prompt for anything. If you need to pass a parameter, that can be done on the MS-Query side. In fact you can read parameters from cells and these cells ma even have formulas like =Today() -30.

    The connection string can be manipulated with code. So if the database has a date stamp and the name can be calculated automatically, the connection can be updated automatically. You can also play with the command string and rewrite the SQL on the fly. We had two tables with identical structures: one held mid-month data and the other end-of-month data. I was able to switch between the tables with a drop down list in a cell.

    Check out MS-Query and let me know if you want to go down that path. I will dig up and send you some more advanced documentation. If so, I should be able to help set you up.

    Microsoft isn't peddling MS-Query as much anymore. It's kind of like an old automobile; it works and it works well but more importantly, it's easy to work on the engine. The modern data access may be flashier, but it's more difficult to manage.
    One spreadsheet to rule them all. One spreadsheet to find them. One spreadsheet to bring them all and at corporate, bind them.

    A picture is worth a thousand words, but a sample spreadsheet is more likely to be worked on.

  3. #3
    Registered User
    Join Date
    05-08-2017
    Location
    Toronto
    MS-Off Ver
    2016
    Posts
    81

    Re: Possible to access... Access database table if file name changes (fixed prefix)?

    Thank you dflak for the suggestion and the in-depth reply. I will certainly look into MS-Query and try learning more about it before getting back to you. Marking as solved.

  4. #4
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Possible to access... Access database table if file name changes (fixed prefix)?

    Here is what I am talking about. This was done for an Oracle database. The pieces of the connection string are different than Access, but the technique is the same. I've done Access before.

    http://www.utteraccess.com/wiki/ODBC...ction_VBA_Code

+ 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. List of Access database paths in Excel - Need to return Access version
    By Wedge120 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-29-2019, 12:19 PM
  2. copy data from one access database to another access database
    By aman1234 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-21-2014, 09:03 AM
  3. Use an Excel Macro in Access VBA - Import text file in Access Table
    By joogibabu in forum Access Tables & Databases
    Replies: 3
    Last Post: 10-08-2014, 10:04 AM
  4. Replies: 2
    Last Post: 07-05-2013, 09:37 AM
  5. How To run Access database without having to install Access on user PC's
    By Reema in forum Access Programming / VBA / Macros
    Replies: 2
    Last Post: 03-26-2009, 04:02 AM
  6. combining multiple access tables in Access Database
    By Reema in forum Access Tables & Databases
    Replies: 3
    Last Post: 03-25-2009, 12:10 AM
  7. importing data from access-database access file
    By amrezzat in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-22-2005, 04:25 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