External Row Source

  • Thread starter Thread starter CC
  • Start date Start date
C

CC

Using Access 2003, I would like a combo box to list file names from an
external location. The user will select the appropriate text file to import.
In the long run, I would like to limit the list to files the user has not
yet imported. Currently the user must type the file name into a text box.
Can someone point me in the right direction to create the combo box?
 
I saved the BrowseFolder API into a new module named BrowseFolder and pasted
your code into the on click event of the combo box. I added the correct
folder to strDirectory, but the combo box does not contain any values. Any
idea what is going wrong?
 
You cannot name the module the same as any functions or subs contained in
the module. However, I would have expected you to get an error, not just
have nothing happen.

Exactly what do you mean that "the combo box does not contain any values"?
Are you saying that the combo box drops down, but you cannot see any values
in the drop down, or that there's nothing (so that the drop down doesn't
drop down)
 
What happens when you compile the code?

Create a button on your form. In the form, try typing (not copying
and pasting...)
Me.cboFiles.

and then you should get Intellisense listing the properties and
methods of the combobox. Is AddItem not listed? What version of
Access are you using?

Compile the code and tell me what error you get. Mine works fine, so
I'm stymied. (Matter of fact, I slapped it together just to see if I
could answer your question.) And post the code too... Then someone
here can figure out what's going on.
 
I renamed the module 'Browse_Folder'.
I do not get intellisense when typing 'Me.cboFiles.'.
I'm getting a compile error: "Method or data member not found." and the
debugger highlights '.cboFiles'

Here's the code:
Private Sub cmdPopulateCombo_Click()

Dim strDirectory As String
Dim strFile As String
Dim i As Integer

strDirectory = BrowseFolder("My Documents")
strFile = Dir(strDirectory & "\*.*")

Do While strFile <> ""
Me.cboFiles.AddItem strFile, i
i = i + 1
strFile = Dir
Loop

End Sub
 
Good thing you asked... I'm still learning. I corrected that issue, but now I
get a pop-up window requiring me to maually browse for the folder that
contains the files I want. This process works, but the files change each day,
and I don't want the user to have to do this. Is there a different API that
will automatically populate the combo box?
 
The API is what's prompting you for the folder.

If the files are always in the same folder, change the line of code

strDirectory = BrowseFolder("My Documents")

to

strDirectory = "C:\Folder"

or wherever it is you want to look.
 
Back
Top