Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

File search/display for all occurrences of Current MDB

Posted on 2010-11-15
7
Medium Priority
?
340 Views
Last Modified: 2012-05-10
There is an access applicatoin that has been changed multiple times and could potentially exist in multiple folders on a given user's pc

I'm trying to write a function that will do a file search on local hard drives for the current mdb name and display the results in a grid.

Not sure of the best way to do this
0
Comment
Question by:johnnyg123
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 77

Accepted Solution

by:
peter57r earned 1000 total points
ID: 34136537
Why do it?
Isn't that what Windows File Search is for?
0
 
LVL 3

Expert Comment

by:bczingo
ID: 34136593

use  Currentdb.Name to get current access mdb

decent recursive file search code here - adapt to get all listings
http://bytes.com/topic/access/answers/209966-recursive-file-search-vba-vs-vb
0
 

Author Comment

by:johnnyg123
ID: 34136848
peter57r


there is a good chance the user does not have a previous version and thus would save the user from having to do a Windows File Search.  

 


0
Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

 

Author Comment

by:johnnyg123
ID: 34138019
I created a sample access db named search_files.mdb

I created a form  named findfiles that has 2 controls

a list box named lstFileName (unbound, row source type = value list)

a command button named cmdFindFile


I added the following to the form



Private Sub cmdFindFile_Click()

dirTest

Me.lstFileName.RowSource = ""

For i = 1 To dlist.Count
     Me.lstFileName.AddItem (dlist(i))
Next i

End Sub



I have a module named search that contains the following:


Option Compare Database

Public dlist As New Collection

Sub dirTest()


Dim startDir As String
Dim i As Integer

Set dlist = Nothing

startDir = "D:\" & CurrentProject.Name

Call FillDir(startDir, dlist)


End Sub


Sub FillDir(startDir As String, dlist As Collection)

' build up a list of files, and then
' add add to this list, any additinal
' folders

Dim strTemp As String
Dim colFolders As New Collection
Dim vFolderName As Variant

strTemp = Dir(startDir)

Do While strTemp <> ""
dlist.Add startDir & strTemp
strTemp = Dir
Loop

' now build a list of additional folders
strTemp = Dir(startDir & "*.", vbDirectory)

Do While strTemp <> ""
If (strTemp <> ".") And (strTemp <> "..") Then
colFolders.Add strTemp
End If
strTemp = Dir
Loop

' now process each folder (recursion)
For Each vFolderName In colFolders
Call FillDir(startDir & vFolderName & "\", dlist)
Next vFolderName

End Sub


There is a file named search_files.mdb  on the root of d:  (d:\)

There is a file named search_files.mdb  in a folder named access  (d:\access)

I was hoping the list box on the form (lstFileName) would contain the following:

d:\search_files.mdb  
d:\access\search_files.mdb  

(since these are where the 2 files exist)


Instead I'm getting

D:\search_files.mdbsearch_files.mdb




Not sure what I'm missing

0
 
LVL 74

Assisted Solution

by:Jeffrey Coachman
Jeffrey Coachman earned 1000 total points
ID: 34143072
Instead of typing all that out, why not just post the DB you tried?
;-)

1. You did not  declare "i" in your button code.
(While this may not have anything to do with the issue, it should be corrected.)

2. Does this code work normally? (before you tried using it in this application)?
(There is no use in troubleshooting code that may not work in the first place)
3. Please comment all of your code.  This is so we don't spend time wondering what every line does.
Sound fair?
;-)
(For example, I am not seeing a delimiter in the code to separate the list Items...?)

4. It is also not clear clear how, exactly, you are running this. (where is the DB located that this code is running from?)

5. It is not clear how this code will return the subfolder paths...?

Basic troubleshooting would say to put a message box in the loops to see what they are returning.
Then you can find out why it is not building the list properly.


While I am certain that this can be done, all of the code to do so is not what I would consider "simple".


Can we go back to Pete's suggestion of using Widows search?
You stated that:
  "there is a good chance the user does not have a previous version and thus would save the user from having to do a Windows File Search. "

I don't understand, ...they must still do a "Search" of one kind or another.

So if they search with your app, or they search with Windows search, they still have to "Search", and the the results will be the same...
I am not understanding how Windows search would be less effective...

JeffCoachman
0
 

Author Closing Comment

by:johnnyg123
ID: 34145023
Ok ...  you guys have convinced me to do a windows search. (i'll raise the white flag and cry uncle)


Thanks for the posts!
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 34151223
;-)
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

618 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