?
Solved

finding all .mdb databases in a directory, open it and find SIMILARLY named tables and perform action

Posted on 2006-05-11
5
Medium Priority
?
164 Views
Last Modified: 2010-05-01
I have a directory with lots of .mdb databases.  The previous programmer used a similar method to email reports generated by these databases after exporting them.  He used a distribution table located in each individual database.  The problem is that most of the names in each distribution list are the same or from a compiled list.  When an employee leaves and another takes his / her place its problematic to 1. FIND all of the relevant databases and 2. update each table in each database with tne new info.

1.)I want to loop over all files in that directory and find files with the .mdb extension (got this)
2.) Open that database (got this)
3.) Open the table (Problem!!!!  not all of the tables are named exactly the same but all have tblDest in the name somewhere)  How do I search for a tablename with a wildcard within the Set rsMyRS = dbMyDB.OpenRecordSet(searchstring, dbOpenDynaset) where searchstring is the table name?

Some tables are named tblDest, some are tbl(two digits that vary)Dest and some are tblDest(then two digits that vary)
I need to search using a wildcard within the openrecordset method but dont know how to pull this off without using a case select statement and putting in all possible names (slow and might as well export each tbldest manually but I have well over 100 databases and growing)

The intent is to import all of these tables naming them  [table name ] & [database of origin name],relate these names to a master table and use a RELATIONAL DATABASE to maintain who gets what report and what the name is, changable as the employees change.

Your help would be appreciated......
'nix
0
Comment
Question by:NWILSON4
  • 3
5 Comments
 
LVL 11

Accepted Solution

by:
TornadoV earned 750 total points
ID: 16661613
You can get an exact table name from MSysObject table and then use that table name as your searchstring:

SELECT MSysObjects.Name
FROM MSysObjects
WHERE (((MSysObjects.Name) Like '*abl*') AND ((MSysObjects.Type)=1));
0
 
LVL 11

Expert Comment

by:TornadoV
ID: 16661622
Sorry, put '*Dest*' instead of '*abl*'

SELECT MSysObjects.Name
FROM MSysObjects
WHERE (((MSysObjects.Name) Like '*Dest*') AND ((MSysObjects.Type)=1));
0
 
LVL 6

Expert Comment

by:junglerover77
ID: 16664270
TornadoV's code is absolutely right.

To get all the mdb files in a particular folder, just try the following code:

    Dim fso As Object
    Dim fol As Object
    Dim fi As Object
   
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set fol = fso.GetFolder("c:\")
    For Each fi In fol.Files
        If UCase(Right(fi.Name, 4)) = ".MDB" Then Debug.Print fi.Name
    Next

Regards,
Jungle
0
 
LVL 15

Expert Comment

by:JackOfPH
ID: 16664481
listening
0
 
LVL 11

Expert Comment

by:TornadoV
ID: 16700395
NWILSON4, I have two questions if I may,

1. Why didn't you split points between junglerover77 and me?
2. Why did you give me 'B'?

0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question