Combo Box reflecting changes in directory

Stacey

Registered User.
Local time
Yesterday, 19:31
Joined
Sep 10, 2002
Messages
84
Hello,
I have a combo box that displays all the files in a specific directory. Below is the On Load event for the form that makes the combo box work (found this by a search, thanks to whoever that was). After they choose the file they want to work with, I have a button to do the import of the file and then I move the file out of that directory. I want the combo box to update at the end of this procedure to only show the files left in the directory. I searched on this and found a few things, such as put the code on the On Activated event, but this just causes the files left in the directory to append to the list that was already showing up. I tried moving it a few different places, like at the end of events on the button for the import, but everything I've tried just tacks on the new list to the end of the old list. Any ideas how to make the combo box update to only show the files that are actually in the directory after I move the file being worked with?


Dim FSO As Object, fld As Object, Fil As Object
Dim SubFolderName As String
Dim i As Integer
Set FSO = CreateObject("Scripting.FileSystemObject")
SubFolderName = "\\cinfile01\custom solution\"
Set fld = FSO.GetFolder(SubFolderName)
For Each Fil In fld.files
i = i + 1
Me.FileComboBox.AddItem Fil.Name

Next Fil


Thanks for any help!
Stacey
 
You could check how many items are in your combobox, and then do a for loop and remove them, and fill it up again. But I don't think I would put it on the activate.
I would make a public sub of it and call it from the form load, and from somewhere else
that updates are taking place. But that is just me.
 

Users who are viewing this thread

Back
Top Bottom