Re: Display list of files in a folder on a hard drive in a form
- From: "Michel Walsh" <vanderghast@VirusAreFunnierThanSpam>
- Date: Wed, 26 Oct 2005 09:49:57 -0400
Hi,
The following should do, assuming the combo box is pre-set to get its list
from a list of values, and with only one column of data:
=================
Public Sub demoDirTxt()
Dim concat As String
Dim str As String
' find all the files in C:\ with the txt extension
str = Dir("C:\*.txt")
Do While str <> vbNullString
' as long as there are file name found, append them to
' what we have already found
concat = concat & IIf(0 = Len(concat), "", ";") & str
' get the next file, if any
str = Dir()
Loop
' assign the list of values we have just built as the combo box list
Forms!formNameHere!ComboBoxNameHere.RowSource = concat
End Sub
================
Hoping it may help,
Vanderghast, Access MVP
"BLTibbs" <BLTibbs@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:AE177B06-8F81-41CB-B5A9-603C0275A7A5@xxxxxxxxxxxxxxxx
>I am too new to code for that to help. I checked the help and couldn't
> figure out how to make it work. What would the code look like?
>
> "Michel Walsh" wrote:
>
>> Hi,
>>
>>
>> Basically you can use the VBA function DIR (see help file for discussion
>> and for an example). You can then recuperate the names in a list box (or
>> combo box) list of values.
>>
>> You can use the file name as if it was an hyperlink to open it.
>>
>>
>> Application.FollowHyperlink "C:\testing.xls"
>>
>>
>>
>> Hoping it may help,
>> Vanderghast, Access MVP
>>
>>
>> "BLTibbs" <BLTibbs@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
>> news:45B33E6C-6D1F-41E9-9A24-7EED8C450B52@xxxxxxxxxxxxxxxx
>> >I have searched and cannot find anything on this. How could I create a
>> >form
>> > that searches the contents of a specific folder on a drive on our
>> > network
>> > and
>> > then have it display all of the files located in the folder on a form.
>> > Then
>> > allow the user to select one file at a time to print or view the
>> > document/file in the program that it was created in?
>>
>>
>>
.
- References:
- Re: Display list of files in a folder on a hard drive in a form
- From: Michel Walsh
- Re: Display list of files in a folder on a hard drive in a form
- Prev by Date: reset listbox
- Next by Date: Re: Username & ComputerName With Access2003
- Previous by thread: Re: Display list of files in a folder on a hard drive in a form
- Next by thread: Re: Display list of files in a folder on a hard drive in a form
- Index(es):
Relevant Pages
|
Loading