Wrox Programmer Forums
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 16th, 2005, 06:09 PM
Registered User
 
Join Date: Jul 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Directory search

I need to search a drive and all Folders under that drive and look in each mdb. database to see if it has a table called "Employees" --- If it has such a table I want the full path & name of that database to be added to the table (probably just the database location)
I am new with VBA and need some help. The code below works fine to get all the tables but I need to only find the one table. I am open to other suggestions.

Private Sub Form_Open(Cancel As Integer)
Dim strFile As String
Dim strPath As String

CurrentDb.Execute "DELETE * FROM tblTables"
strPath = "c:\" 'Change the path to whereever you need it to be
strFile = Dir(strPath & "*.mdb")

While strFile <> ""
CurrentDb.Execute "INSERT INTO tblTables (TableName, DatabaseName) SELECT Name,'" & strPath & strFile & "' FROM MSysObjects IN '" & strPath & strFile & "' WHERE Left$(Name,1)<>'~' AND Type=1"
   strFile = Dir()
Wend
Me!Combo0.Requery

End Sub


I am using Access2000

 
Old July 30th, 2005, 03:08 AM
Friend of Wrox
 
Join Date: Jul 2005
Posts: 150
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You are not getting table names but database name.

If you are looking for a table, then after you find a database (MDB file). then you can use ADO or DAO to open the database and look for the table name.


If you are really looking for a single database name then:

strFile = Dir(strPath & "mydatabase.mdb")

will only find the database file named: mydatabase.mdb within the directory.



Boyd
Access Based Accounting/Business Solutions developer.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Search button doesn't search Access DB cbones Visual Studio 2008 1 October 27th, 2008 07:36 PM
New text search doesn't preselect search string planoie Visual Studio 2005 0 July 23rd, 2007 06:47 AM
Search Engine for Full-text Search Kala ASP.NET 1.0 and 1.1 Professional 2 August 29th, 2004 02:16 AM
search for null /String.Empty in Active Directory georgeh C# 1 October 16th, 2003 08:09 AM
Search engine that search through local drive! wenzation Classic ASP Basics 0 August 26th, 2003 09:15 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.