Thanks so much. I got it to work, but with one problem.
It won't run in Access2000. Apparently the
object "additem" is not recognized. Do you know if
there's a reference I need to activate for that? Thanks.
Tim
-----Original Message-----
Why are you putting "C:\Test" into the control source.
This is a text box
so just type this into the text box not the control
source. Access thinks
that this is a field in the underlying table and since
its not, it won't
find that field and that why you are getting the error
message. Leave the
control source blank.
To get a list of TXT files only, just change the "*"
to "*.TXT".
Kelvin
message
Thanks alot Kelvim. This looks promising, but still
having trouble. If I don't specify the directory, I
get
a list of some of the files on my c:\ drive. But as
soon
as I put "c:\test" in the control source for
the "txtpath" text box I get a run-time error-2424 and
a
message that says access can't find field, control, or
property name. Any ideas? Also, at the risk of
getting
greedy, is there a way in which only .txt files could
be
listed? Thanks so much for your help.
-----Original Message-----
This should only work for combo boxes and list boxes.
Set the source type
for the box to a Value list. If the list box or combo
box has a
record/table source, the AddItem property does not
work.
Kelvin
"rWaag" <richwaag.at.earthlink.net> wrote in message
Kelvin-
I am trying something similar but this code didn't
work. VBA does not
support ADDITEM for list or combo boxes- unless I'm
missing something.
Rich
Try putting this in the forms OnCurrent event
Dim nyPath as String
Dim myFile As String
Dim intIndex As Integer
myPath = [txtPath] & "\*"
myFile = Dir(myPath)
intIndex = 0
Do While myFile <> ""
Me.[ListBox].AddItem Item:=myFile,
Index:=intIndex
myFile = Dir()
intIndex = intIndex + 1
Loop
This will populate the list box called ListBox
with
files in the
directory
in the text box called txtPath. If you want to
enter [txtPath], then
put
the code in the afterupdate event of the text box.
Kelvin
"tim s." <
[email protected]>
wrote
in message
Thanks for your response. Unfortunately, I'm
looking for
a dynamic list that will show all files in the
directory. As the list will be constantly
changing, a
permanent table might not help too much in this
case.
Any other thoughts?
Thanks
Tim
-----Original Message-----
Try KB 158941. This is a routine to load OLE
objects
(with a specific
extension) into a table along with the
filenames. You
can probably modify
it to leave out the OLE part and just laod the
filenames. You can then use
this table to populate the list box.
Kelvin
"Tim S."