Locate files in a specific folder

K

kuslusr1

I am currently using form code I obtained from a Doug Steele link, works very
well. I would like to use the code to locate files in a specific drive and
folder like: F drive, Music folder.

Private Sub cmdFind_Click()
' Open the File Open dialog to find an MP3.
On Error GoTo Err_cmdFind_Click

Dim strFilter As String
Dim strInputFileName As String

' Set the filter to only look for MP3s
strFilter = ahtAddFilterItem(strFilter, "MP3s (*.MP3)", "*.MP3")
strInputFileName = ahtCommonFileOpenSave( _
Filter:=strFilter, OpenFile:=True, _
DialogTitle:="Please select an MP3 file...")

If Len(strInputFileName) > 0 Then
If Len(Dir(strInputFileName)) > 0 Then
Me.txtMP3 = strInputFileName
' Call txtMP3_AfterUpdate to ensure that the same actions happen as if they'd
' keyed a file name in.
Call txtMP3_AfterUpdate
End If
End If

End_cmdFind_Click:
Exit Sub

Err_cmdFind_Click:
msgbox Err.description & " (" & Err.Number & ") in " & _
Me.name & ".cmdFind_Click", _
vbOKOnly + vbCritical, "Smart Access Answer Column"
Resume End_cmdFind_Click

End Sub
 
K

Klatuu

You can use the InitialDir parameter in this code so that it is in the
specified folder when the dialog is presented:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top