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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

List Files in a Text Box

Status
Not open for further replies.

adamr99

Programmer
Jun 25, 2001
59
US
I have the need to list files in a text box (or any other way for that matter) in a form that I am creating.

The files will be all in one directory, however, not the same directory that the access database will be in.

For all of you super users out there, I eventually will want to make the file list into a Link-List, so that the files can be opened through the form. Any Ideas on setting up any of this?
 
Hi!

Try following codes for creating file list:

Private Sub Form_Load()
dim strFileList as string
dim i as integer
dim strLocation as string

strLocation = "C:\MyDirectory\"
With Application.FileSearch
.LookIn = strLocation
.FileName = "*.*"
.SearchSubFolders = True
If .Execute > 0 Then
For i = 1 To .FoundFiles.Count
If Len(strFileList) > 0 Then
strFileList = strFileList + ";"
End If
strFileList = strFileList + .FoundFiles(i)
Next i
Me.lstFileList.RowSource = strFileList
else
msgbox "There are not files on this location:" & vblf & strLocation
Me.lstFileList.visible=false
End If
End With
end sub

Aivars
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top