Search for folders on a drive then open that folder if it is found. (1 Viewer)

Johnta

New member
Local time
Today, 14:16
Joined
Jul 9, 2009
Messages
7
Is it possible to create a file system that could search for a record using wild card characters then open the file if it is found. For example my DB form is something in the effect of http://allenbrowne.com/ser-62.html I want the user to be able to click on one of the records shown then I want my application to search a predetermined drive, say the I drive, and if the ID is found, say the name of the Folder is cutomer1 so I guess it would have to have some kind of wild card expression, then I want it to open that folder and display the results to the user. Is this possible? There may not be a folder for every customer, and the naming conventions used for the folder may be different so it would have to be a wild card. Of course My Id field is a little more specific so im not so worried about it finding multiple folders that share common numbers.
 

ezfriend

Registered User.
Local time
Today, 14:16
Joined
Nov 24, 2006
Messages
242
Are you looking for a directory searching? or just checking to see if a file/folder exists?

If you are looking for a directory searching, I do have code that can loop through directories/files. If just check for file/folder existance, use the DIR$ function.
 

Johnta

New member
Local time
Today, 14:16
Joined
Jul 9, 2009
Messages
7
I want to check and see if the file/folder exist, and if it does I want VB to open the folder and display the contents to the user. For example the user would click ID number 1122, then the application would search the I drive for folder 1122, then if a folder contains 1122 in the file name the program opens the folder and displays the results to the user.
 

Johnta

New member
Local time
Today, 14:16
Joined
Jul 9, 2009
Messages
7
Private Sub Text30_Click()
Dim sUserFile As String
sUserFile = Dir$("L:\Test Results\TR'S\TR" & Text30.Text, vbDirectory)

On Error GoTo err
Dim bb
bb = Shell("Explorer.exe L:\Test Results\TR'S\" & sUserFile, 1)
Exit Sub
err:
MsgBox err.Description



End Sub

This is my code so far. I cant get it to search in subdirectories and I would be albe to leave out the TR if I could get some kind of wild card expression after TR's. like L:\Test Results\TR'S\*.text30 but that expression wont work. I Havent used VB for years and even then I didnt have to much experience somebody help plz.
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 22:16
Joined
Sep 12, 2006
Messages
15,728
unfortunately dir function is not recursive, and wont search subdirectories.

you have to store your own folder tree, and feed it in to dir, to do this - or find another way completely.
 

Johnta

New member
Local time
Today, 14:16
Joined
Jul 9, 2009
Messages
7
Creating my own folder tree would be a massive amount of data. Ive seen recusive ways to view files but what about just folders?
 

Users who are viewing this thread

Top Bottom