Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Find folder using fuzzy search and open 1

Status
Not open for further replies.

smandoli9

Programmer
Jun 10, 2002
103
US
I'm building a project management application (Access 2003). Each project has a folder on the network which serves as a hold-all for various documents. I want the Details Form for a given project to include a button that will open the relevant folder.

Application.FollowHyperlink "network\path" opens a folder -- behaves just the way I want it to. The problem is with providing the path. The folders are consistently placed on the network, but they are named somewhat arbitrarily, and it's not possible to deduce the full path.

The good news is, the first six characters of the target folder are fully consistant. It's stuff that follows that is arbitrary.

So what I am looking for essentially is:

strPathStart = "network path\goes for all projects\"
strPathFolder_6_digit = "Solid Start"
Search for folders whose path is like strPathStart & strProjectFolder_6_digit & Wildcard

If Count of such folders = 1 Then
strPathComplete = the search result
Application.FollowHyperlink strPathComplete
Else
MsgBox "Sorry, can't locate that folder!"
End If


I find API calls that will search across a network, using wildcards. The problem is they pull up all types of documents, and I am looking for a folder. msoFileType seemed to provide a way to restrict the search, but folder is not one of the types that it references.

Any ideas?

[purple]_______________________________
Never confuse movement with action -- E. Hemingway [/purple]
 
Something like this ?
strPathComplete = Dir(strPathStart & strProjectFolder_6_digit & "*", vbDirectory)
If strPathComplete <> "" And Dir = "" Then
Application.FollowHyperlink strPathComplete
Else
MsgBox "Sorry, can't locate that folder!"
End If

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
You're like some kind of doctor who cured cancer or AIDS. Your party affiliation matters not -- I'm voting you for President. Probably I am exaggerating but anyway I am very grateful for this solution.

FYI, Future Seekers:
And Dir = "" should be
And Dir <> ""


Smandoli


Houston prayed, and prayer works.

[purple]_______________________________
Never confuse movement with action -- E. Hemingway [/purple]
 
Hello,
I found this post very useful...but I'm stuck.

I've changed
Code:
strPathComplete = Dir(strPathStart & strProjectFolder_6_digit & "*", vbDirectory)

to
Code:
strPathComplete = Dir(strPathStart & strProjectFolder & "*", vbDirectory)

however, my return string only gives me the second part "strPathProject" piece so as a result I get the message box telling me the folder does not exist.

I am trying to base their request for directory based on the Project ID found on the main form. Here's all of my code for the "Find all documents" button OnClick event.

Code:
Private Sub cmdBrowse_Click()
  
  
  Dim strPathStart As String
  Dim strProjectFolder As String
  Dim strPathComplete As String
  
    strPathStart = "\\BAS1b\JDRIVE\Projects\PTDb\"
    strProjectFolder = Me!txtPROJ_ID
    strPathComplete = Dir(strPathStart & strProjectFolder & "*", vbDirectory)
        If strPathComplete <> "" And Dir <> "" Then
            Application.FollowHyperlink strPathComplete
        Else
            MsgBox "Sorry, can't locate that folder!"
        End If
      
End Sub

TIA for any help.
 
This required some troubleshooting for me too. Check this out:
Code:
    strTargetFolder = Dir(strPathStart & strProjNum & "*", vbDirectory)
    
    strPathComplete = strPathStart & strTargetFolder
    If strPathComplete <> "" And strTargetFolder <> "" Then
        Application.FollowHyperlink strPathComplete, , True
    Else
        MsgBox "Sorry, can't locate that folder!"
        'Stop
    End If
I think you'll notice I had to first get the final bit of the path using Dir and a wildcard; then add it to the rest of the path; then use that for the FollowHyperlink.




Pt. Arthur also prayed. My friend pointed this out.
(He also believes prayer works.)

[purple]_______________________________
Never confuse movement with action -- E. Hemingway [/purple]
 
Sweet hallelujah it works!

I'm building much the same thing. A project database for the big boss to check up on everyone's progress.

THANK YOU!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top