bldnbtfl
07-18-2001, 07:11 PM
Access 2000...
With the help of someone on this forum, I was able to populate a combo box with the filenames in a given folder.
There appears to be a limitation however.
Here is the code......
Private Sub Form_Open()
'Code to populate project report combo box with directory contents
Dim str_filename As String
Dim str_filenames As String
' Change folder path below as desired:
str_filenames = Dir$("c:\windows\desktop\*.*")
Do
str_filename = Dir
str_filenames = str_filenames & ";" & str_filename
Loop Until str_filename = ""
cmb_filenames.RowSource = str_filenames
cmb_filenames.Value = Mid$(str_filenames, 1, InStr(str_filenames, ";") - 1)
End Sub
As this code is written, it will run fine, but change the directory to say, C:\windows\system\ it dies because the directory is chock full of files.
The code works until the directory exceeds X number of files. What that exact limitation is, I don't know. Maybe it's a limit on the number of characters allowed in a string. Again, I don't know.
We already have more files in the folder on the server than the code can handle, and we add a couple more every week.
Is there a way around this? What I am trying to do is allow the user to open the Word document associated with a particular record.
The other approach I tried was creating a table of the directory filenames which we will have to manually update. This extra step is acceptable, however, using SHELL fails because of spaces in the directory path and spaces in the filenames.
Thanks.
With the help of someone on this forum, I was able to populate a combo box with the filenames in a given folder.
There appears to be a limitation however.
Here is the code......
Private Sub Form_Open()
'Code to populate project report combo box with directory contents
Dim str_filename As String
Dim str_filenames As String
' Change folder path below as desired:
str_filenames = Dir$("c:\windows\desktop\*.*")
Do
str_filename = Dir
str_filenames = str_filenames & ";" & str_filename
Loop Until str_filename = ""
cmb_filenames.RowSource = str_filenames
cmb_filenames.Value = Mid$(str_filenames, 1, InStr(str_filenames, ";") - 1)
End Sub
As this code is written, it will run fine, but change the directory to say, C:\windows\system\ it dies because the directory is chock full of files.
The code works until the directory exceeds X number of files. What that exact limitation is, I don't know. Maybe it's a limit on the number of characters allowed in a string. Again, I don't know.
We already have more files in the folder on the server than the code can handle, and we add a couple more every week.
Is there a way around this? What I am trying to do is allow the user to open the Word document associated with a particular record.
The other approach I tried was creating a table of the directory filenames which we will have to manually update. This extra step is acceptable, however, using SHELL fails because of spaces in the directory path and spaces in the filenames.
Thanks.