Jibbadiah
James
- Local time
- , 10:55
- Joined
- May 19, 2005
- Messages
- 282
Folks,
I have been using a piece of code from Ghudson for some time and it works really well. It is used to display the files in a directory as a value list in a combo box. I use it as a way of allowing the users to link to archived files and reload them if they need to view an old report. What would be nice is if I could sort the files before creating the value list.
The file list looks like follows (but many more files):
PROSPECTS 04-May-2006 at 12.33.12 PM.TXT
PROSPECTS 11-Jan-2006 at 04.12.44 PM.TXT
PROSPECTS 14-Jul-2006 at 14.08.55 PM.TXT
PROSPECTS 16-Aug-2006 at 15.25.11 PM.TXT
PROSPECTS 21-Dec-2005 at 16.06.03 PM.TXT
The code above seems to be sorting alphabetically in ascending order. If poss I would prefer to sort by year and then month and then day(ASC order):
PROSPECTS 21-Dec-2005 at 16.06.03 PM.TXT
PROSPECTS 11-Jan-2006 at 04.12.44 PM.TXT
PROSPECTS 04-May-2006 at 12.33.12 PM.TXT
PROSPECTS 14-Jul-2006 at 14.08.55 PM.TXT
PROSPECTS 16-Aug-2006 at 15.25.11 PM.TXT
Any suggestions?
Cheers,
James
I have been using a piece of code from Ghudson for some time and it works really well. It is used to display the files in a directory as a value list in a combo box. I use it as a way of allowing the users to link to archived files and reload them if they need to view an old report. What would be nice is if I could sort the files before creating the value list.
Code:
Const cPath = "\\Server\Directory\"
Dim sPath As String
Dim sFileList As String
Dim sFileName As String
sFileList = ""
sFileName = Dir(cPath)
Do While sFileName <> ""
If sFileName Like "PROSPECTS *" Then
sFileList = sFileList & sFileName & ";"
End If
sFileName = Dir
Loop
Me.cbSelectFile.RowSource = sFileList
Me.cbSelectFile.Requery
The file list looks like follows (but many more files):
PROSPECTS 04-May-2006 at 12.33.12 PM.TXT
PROSPECTS 11-Jan-2006 at 04.12.44 PM.TXT
PROSPECTS 14-Jul-2006 at 14.08.55 PM.TXT
PROSPECTS 16-Aug-2006 at 15.25.11 PM.TXT
PROSPECTS 21-Dec-2005 at 16.06.03 PM.TXT
The code above seems to be sorting alphabetically in ascending order. If poss I would prefer to sort by year and then month and then day(ASC order):
PROSPECTS 21-Dec-2005 at 16.06.03 PM.TXT
PROSPECTS 11-Jan-2006 at 04.12.44 PM.TXT
PROSPECTS 04-May-2006 at 12.33.12 PM.TXT
PROSPECTS 14-Jul-2006 at 14.08.55 PM.TXT
PROSPECTS 16-Aug-2006 at 15.25.11 PM.TXT
Any suggestions?
Cheers,
James