List box display of external text files

R

richardb

I would like to create a list box on a form that will display the external
files of type *.txt located in a certain folder. I would appreciate help how
to do this.

My intention is to import the selected file into an Access Table. I think I
can do that part but any suggestions would be helpful.

Thank you, Richard
 
R

richardb

I looked under "More Controls" button but do not see the Common Dialog
Control. Yes, you remind me that it would be the best solution, but I can't
locate it.
 
J

John Nurick

Why not try the link I sent you?

I looked under "More Controls" button but do not see the Common Dialog
Control. Yes, you remind me that it would be the best solution, but I can't
locate it.
 
R

richardb

Because I don't remember the Common Dialog Control requiring me to write that
huge amount of code and I could not understand the code. I recall that there
is someway to use the CDC that is pretty straight forward. I don't know what
I'm missing here.
 
D

Douglas J. Steele

While it's true that the Common Dialog Control doesn't require much code,
it's also extremely prone to versioning problems. Even if you aren't
distributing your application to others, if you install new software on your
workstation, the CDC may stop working.

It really doesn't matter whether you understand the code to work with the
API. Let's face it, you have no idea what code is "under the covers" when
you use the CDC! Copy the code from the given reference into a module, and
then you need 2 lines of code to use it (4 if you count the declarations):

Dim strFilter As String
Dim strInputFileName as String

strFilter = ahtAddFilterItem(strFilter, "Text Files (*.txt)", "*.txt")
strInputFileName = ahtCommonFileOpenSave( _
Filter:=strFilter, OpenFile:=True, _
DialogTitle:="Please select an input file...", _
Flags:=ahtOFN_HIDEREADONLY)
 
R

richardb

I will try to do as you suggest. In the mean time, however, I'm working with
the CDC and cannot find a list of methods and properties in my on-line help.
When I enter cdlViewer.<property list> I don't see these. I have a button
that lauches the CDC (called cdlViewer). I need the OnClick event to obtain
the path from a table entry and set the property equal to IntDir on property
sheet. I don't know what this property is called in code. I'd like to obtain
all the methods and properties.

Also, what is the difference between cdlViewer.ShowOpen and
cdlViewer.ShowSave. In either case I can save the result with
strFileName = cdlViewer.FileName

Thanks...
 
R

richardb

Douglas,

I have tried the code by copying it into a module and then attempted to run
the TestIt function. I must have some missing libraries. For CurDir, I get
the Compile Error "Can't find project or Library". This refers to
compatui.dll. Even the "string" function produces the same. I guess I need to
install an option or library.
 
R

richardb

Forgot to mention I am running MS Access 2002. It is part of Office XP
developer edition.
 
R

richardb

I found a list of CDC methods and properties at
http://exchange.manifold.net/manifold/manuals/5_userman/mfd50Control__Common_Dialog_Control.htm

Other questions remain...thanks...

richardb said:
I will try to do as you suggest. In the mean time, however, I'm working with
the CDC and cannot find a list of methods and properties in my on-line help.
When I enter cdlViewer.<property list> I don't see these. I have a button
that lauches the CDC (called cdlViewer). I need the OnClick event to obtain
the path from a table entry and set the property equal to IntDir on property
sheet. I don't know what this property is called in code. I'd like to obtain
all the methods and properties.

Also, what is the difference between cdlViewer.ShowOpen and
cdlViewer.ShowSave. In either case I can save the result with
strFileName = cdlViewer.FileName

Thanks...
 
D

Douglas J. Steele

I have no idea what compatui.dll is: it's certainly not part of Access (and
definitely isn't required to run the code in that sample). My suspicion is
that you have a References problem that has nothing to do with using that
code.

References problems can be caused by differences in either the location or
file version of certain files between the machine where the application was
developed, and where it's being run (or the file missing completely from the
target machine). Such differences are common when new software is installed.

On the machine(s) where it's not working, open any code module (or open the
Debug Window, using Ctrl-G, provided you haven't selected the "keep debug
window on top" option). Select Tools | References from the menu bar. Examine
all of the selected references.

If any of the selected references have "MISSING:" in front of them, unselect
them, and back out of the dialog. If you really need the reference(s) you
just unselected (you can tell by doing a Compile All Modules), go back in
and reselect them.

If none have "MISSING:", select an additional reference at random, back out
of the dialog, then go back in and unselect the reference you just added. If
that doesn't solve the problem, try to unselect as many of the selected
references as you can (Access may not let you unselect them all), back out
of the dialog, then go back in and reselect the references you just
unselected. (NOTE: write down what the references are before you delete
them, because they'll be in a different order when you go back in)

For far more than you could ever want to know about this problem, check out
http://members.rogers.com/douglas.j.steele/AccessReferenceErrors.html




--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



richardb said:
Douglas,

I have tried the code by copying it into a module and then attempted to
run
the TestIt function. I must have some missing libraries. For CurDir, I get
the Compile Error "Can't find project or Library". This refers to
compatui.dll. Even the "string" function produces the same. I guess I need
to
install an option or library.
 
R

richardb

OK that did it. Unselecting the MISSING libraries got rid of all
run-time/compile errors. I also think I've figured out how to use the code.
I'm satisfied to close this thread with my sincere thanks.

However, if you feel like it, I do still have a question from the Common
Dialog: When I try to use the property (or is it a method) called
..HideReadOnly, I get error 438 - property or method not supported. Can you
tell me how come?...
 
D

Douglas J. Steele

Sorry, I don't know: I've never bothered with the control myself.

Looking at the reference you gave for getting information about the CDC, I'm
wondering whether that's a custom version of the control they're talking
about.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top