Hi,
I have a form with 2 combo boxes.
I am not using them in the usual way, please read on:
In the 'Form Load' event, I have:
_______________________________________
dim folderspec as string
folderspec = "\\server\Images" (These folders are on our network
server in the office).
Dim fs, f, f1, fc, s
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(folderspec)
Set fc = f.SubFolders
For Each f1 In fc
Me.Combo1.AddItem f1.name
Next
________________________________________
This lists all the sub-folder names within the main folder 'Images'
.....great so far. I then select a specific folder name from Combo1.
In Combo1 'After Update' I have this code:
_________________________________________
All the following variables are public.
'folder' is a public varable which holds the selected folder name from
combo1.
folder = ""
FileScript = ""
FolderPath = ""
FileSet = ""
folder = Me.Combo11.Column(0)
Dim strFiles As String
Set FileScript = CreateObject("Scripting.FileSystemObject")
Set FolderPath = FileScript.GetFolder("\\server\Images\" & folder)
Set FileSet = FolderPath.Files
For Each FileSelection In FileSet
Me.Combo2.AddItem FileSelection.name
Next
__________________________________________________ ___________
This works great the first time I select a folder from combo1, combo2
lists all the files within it, but the next time I se;ect another
folder from combo1, all those files are added to combo2 in addition to
the previous files instead of just changing them to the new files ? How
can I clear Combo2 for the next time I select from combo1 ?
I've tried n umerous things such as:
me.combo2 = null
me.combo2.text = ""
none of them seem to make any difference ? Combo2 always gets loaded
with more and more file names...I can understand why this happens, I
just cannot seem to clear combo2 ?
Thanks
David Gordon