Listing all Access files in a particular folder

kcarpy

Registered User.
Local time
Today, 09:31
Joined
Feb 7, 2008
Messages
13
Hi. I'm working on a form that lets the user import data from another Access database. I'd like to let them choose a database from a particular path. In order to do that, I'd like to have a combo box containing the names of all Access files in that path.

I am able to get all the files with this code:
Code:
Function UpdateFiles()

Dim dir, folder, files

Forms!fimport!filename.RowSource = ""

dir = Forms!fimport!path
Set fso = CreateObject("Scripting.FileSystemObject")
Set folder = fso.GetFolder(dir)
Set files = folder.files

Forms!fimport!filename.RowSourceType = "Value List"
For Each file In files
Forms!fimport!filename.AddItem (file.Name)
Next


End Function

How can I filter out any files that are not .accdb files?

Thanks in advance for any help.
 
Code:
For Each file in files
     If Right(file.Name,6) = ".accdb" Then
          Forms!fimport!filename.AddItem (file.Name)
     End If
Next
 
Of course. I don't know why I didn't think of that.

Thank you!
 

Users who are viewing this thread

Back
Top Bottom