Dear All,
I have a user form with a listbox. On userform initialize event, I have a code that display all the .mdb file in the listbox. But the problem is the items are sorted alphabetically by the month name. Is that possible to list the file as per the date created from the latest to the oldest?
Thanks for the help
Baha
Here is my code:
I have a user form with a listbox. On userform initialize event, I have a code that display all the .mdb file in the listbox. But the problem is the items are sorted alphabetically by the month name. Is that possible to list the file as per the date created from the latest to the oldest?
Thanks for the help
Baha
Here is my code:
Code:
Private Sub UserForm_Initialize()
AllocationOB = True
ListBoxStartUp
End Sub
Sub ListBoxStartUp()
Dim fileList() As String
Dim fName As String
Dim fPath As String
Dim i As Integer
fPath = "P:\Everyone\For Baha\Gaming Common\Sands_VirtualCP" & "\BackUpDataFiles\"
fName = Dir(fPath & "*.mdb")
While fName <> ""
i = i + 1
ReDim Preserve fileList(1 To i)
fileList(i) = fName
'get next filename
fName = Dir()
Wend
'see if any files were found
If i = 0 Then
MsgBox "No files found"
Exit Sub
End If
'cycle through the list and add to listbox
For i = 1 To UBound(fileList)
Me.FilesListBox.AddItem fileList(i)
Next
End Sub