File list box

  • Thread starter Thread starter Tim S.
  • Start date Start date
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
 
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
 
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
 
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


Kelvin said:
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. said:
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
 
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 said:
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


Kelvin said:
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. said:
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

message
Hi. I'm trying to get a list of text files in a
certain
directory to show up on my form. I've tried the code
below, but when I open the form there is no recognition
of any files in the directory. Does anyone have any
ideas?

Thanks

Tim

http://support.microsoft.com/default.aspx?scid=kb;en-
us;308634&Product=acc


.
 
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 said:
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


Kelvin said:
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 enter [txtPath], then
put

.
 
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

Tim S. said:
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 said:
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

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

message
Hi. I'm trying to get a list of text files in a
certain
directory to show up on my form. I've tried the code
below, but when I open the form there is no recognition
of any files in the directory. Does anyone have any
ideas?

Thanks

Tim

http://support.microsoft.com/default.aspx? scid=kb;en-
us;308634&Product=acc


.


.
 
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

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

message
Hi. I'm trying to get a list of text files in a
certain
directory to show up on my form. I've tried the code
below, but when I open the form there is no recognition
of any files in the directory. Does anyone have any
ideas?

Thanks

Tim

http://support.microsoft.com/default.aspx? scid=kb;en-
us;308634&Product=acc


.







.


.
 
AddItem is a built-in property to combo boxes and list boxes. It's been
there since at least Access 97, maybe even earlier. Is the source type set
to value list. This is the only way you can use the AddItem property.

Kelvin

Tim S. said:
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

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

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." <[email protected]>
wrote in
message
Hi. I'm trying to get a list of text files in a
certain
directory to show up on my form. I've tried
the code
below, but when I open the form there is no
recognition
of any files in the directory. Does anyone
have any
ideas?

Thanks

Tim

http://support.microsoft.com/default.aspx?
scid=kb;en-
us;308634&Product=acc


.







.


.
 
the source type is set to value list. I can get this to
work in Access 2002. But when I put it into Access 2000
it doesn't work. The error message says "Compile error:
Method or data member not found" and
highlights .AddItem. Any other possibilities? I realize
this feature has existed in Visual Basic for a long
time. But I found references that said this was a new
feature in Access 2002 and later. Could it be that the
VisualBasic for Applications associated with Access2000
doesn't recognize it? Sorry to keep pestering you with
this. Thanks alot

tim
-----Original Message-----
AddItem is a built-in property to combo boxes and list boxes. It's been
there since at least Access 97, maybe even earlier. Is the source type set
to value list. This is the only way you can use the AddItem property.

Kelvin

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

"Tim S." <[email protected]> wrote
in
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

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."
wrote in
message
[email protected]...
Hi. I'm trying to get a list of text
files
in a
certain
directory to show up on my form. I've tried
the code
below, but when I open the form there is no
recognition
of any files in the directory. Does anyone
have any
ideas?

Thanks

Tim

http://support.microsoft.com/default.aspx?
scid=kb;en-
us;308634&Product=acc


.







.



.


.
 
I guess I was worng about it being in earlier versions of Access. I just
checked on an old machine that has Access97 and additem isn't there. I
don't have 2000 to check but I'm guessing its not there either since you
can't get it to work. If you look in the help under RowSourceTpye Property
you will see an example of a function that list MDB files in a listbox. You
can modify this using the current code for your files. Once you've got the
function created you can use this instead of the current method since the
function method will work for all versions of Access.

Kelvin

Tim S. said:
the source type is set to value list. I can get this to
work in Access 2002. But when I put it into Access 2000
it doesn't work. The error message says "Compile error:
Method or data member not found" and
highlights .AddItem. Any other possibilities? I realize
this feature has existed in Visual Basic for a long
time. But I found references that said this was a new
feature in Access 2002 and later. Could it be that the
VisualBasic for Applications associated with Access2000
doesn't recognize it? Sorry to keep pestering you with
this. Thanks alot

tim
-----Original Message-----
AddItem is a built-in property to combo boxes and list boxes. It's been
there since at least Access 97, maybe even earlier. Is the source type set
to value list. This is the only way you can use the AddItem property.

Kelvin

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."
wrote in
message
[email protected]...
Hi. I'm trying to get a list of text files
in a
certain
directory to show up on my form. I've tried
the code
below, but when I open the form there is no
recognition
of any files in the directory. Does anyone
have any
ideas?

Thanks

Tim

http://support.microsoft.com/default.aspx?
scid=kb;en-
us;308634&Product=acc


.







.



.


.
 
Sounds good. Thanks alot for all your help

Tim

-----Original Message-----
I guess I was worng about it being in earlier versions of Access. I just
checked on an old machine that has Access97 and additem isn't there. I
don't have 2000 to check but I'm guessing its not there either since you
can't get it to work. If you look in the help under RowSourceTpye Property
you will see an example of a function that list MDB files in a listbox. You
can modify this using the current code for your files. Once you've got the
function created you can use this instead of the current method since the
function method will work for all versions of Access.

Kelvin

the source type is set to value list. I can get this to
work in Access 2002. But when I put it into Access 2000
it doesn't work. The error message says "Compile error:
Method or data member not found" and
highlights .AddItem. Any other possibilities? I realize
this feature has existed in Visual Basic for a long
time. But I found references that said this was a new
feature in Access 2002 and later. Could it be that the
VisualBasic for Applications associated with Access2000
doesn't recognize it? Sorry to keep pestering you with
this. Thanks alot

tim
-----Original Message-----
AddItem is a built-in property to combo boxes and list boxes. It's been
there since at least Access 97, maybe even earlier.
Is
the source type set
to value list. This is the only way you can use the AddItem property.

Kelvin

"Tim S." <[email protected]> wrote
in
message
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

"Tim S." <[email protected]>
wrote
in
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
news:uvU%23D% (e-mail address removed)...
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."
wrote
in message
[email protected]...
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."
wrote in
message
[email protected]...
Hi. I'm trying to get a list of text files
in a
certain
directory to show up on my form. I've tried
the code
below, but when I open the form there
is
no
recognition
of any files in the directory. Does anyone
have any
ideas?

Thanks

Tim

http://support.microsoft.com/default.aspx?
scid=kb;en-
us;308634&Product=acc


.







.



.



.


.
 
Back
Top