Allen Browne DirListBox Module (1 Viewer)

DaaAgent

Registered User.
Local time
Today, 14:31
Joined
Dec 5, 2005
Messages
49
Hello

I have been trying to change 1 of Allen Browne helpful examples in my Access2000 db

I would like to change 2 things

1. On the current record ID Fill-in the files from the Specific Folder
I believe this is the line I should change
StrFileName = Dir$("C:\") ' Read filespec from a form here???
The folder path is \\Rtserver\Tracker\EID_AID_Folders\EID????\

2. Add code to the Double Click event to open the specific file

Thanks in advance for your help

Function DirListBox (fld As Control, ID, row, col, code)
' Purpose: To read the contents of a directory into a ListBox.
' Usage: Create a ListBox. Set its RowSourceType to "DirListBox"
' Parameters: The arguments are provided by Access itself.
' Notes: You could read a FileSpec from an underlying form.
' Error handling not shown. More than 512 files not handled.
Dim StrFileName As String
Static StrFiles(0 To 511) As String ' Array to hold File Names
Static IntCount As Integer ' Number of Files in list

Select Case code
Case 0 ' Initialize
DirListBox = True

Case 1 ' Open: load file names into array
DirListBox = Timer
StrFileName = Dir$("C:\") ' Read filespec from a form here???
Do While Len(StrFileName) > 0
StrFiles(IntCount) = StrFileName
StrFileName = Dir
IntCount = IntCount + 1
Loop

Case 3 ' Rows
DirListBox = IntCount

Case 4 ' Columns
DirListBox = 1

Case 5 ' Column width in twips
DirListBox = 1440

Case 6 ' Supply data
DirListBox = StrFiles(row)

End Select
End Function
 

Mr_Si

Registered User.
Local time
Today, 22:31
Joined
Dec 8, 2007
Messages
163
I've just come accross this and I have a question, as I'm trying to read a list of files from a directory into a listbox.

I have a question for you...

How do you set the listbox's RowSourceType to "DirListBox"? I only have Table/Query, ValueList and FieldList available.

I'm using Access 2007

Thanks,

A Confused Mr. Si
 

Users who are viewing this thread

Top Bottom