Re: find and display files



Sorry, my typo.

When using named parameters (such as InitialDir), you use :=, not =.

Private Sub pdf1_Click()
Dim strFilter As String
Dim strFolder As String
Dim strInputFileName As String

strFolder = "\\jsnet\drawingofficeintranet\zz publication order\"
strFilter = ahtAddFilterItem(strFilter, "PDF Files (*.PDF)", _
Me!SomeTextBox & "*.PDF")
strInputFileName = ahtCommonFileOpenSave( _
InitialDir := strFolder, _
Filter:=strFilter, OpenFile:=True, _
DialogTitle:="Please select an input file...", _
Flags:=ahtOFN_HIDEREADONLY)

End Sub


--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"gymphil" <gymphil@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:186956A4-024D-4F99-A699-43F0F52936B3@xxxxxxxxxxxxxxxx
Doug,

I used the same code with slight variations a number of times on the same
form. I take it that cannot be done? I have now removed all the duplicated
constants. What happens now is that I still get the same compile error,
having searched the modules the only other place this appears is in the
code
from: http://www.mvps.org/access/api/api0001.htm, not only that but the
InitialDir parameter is not working now either, it has reverted back to
opening the C directory. One step forward and two back.



Private Sub pdf1_Click()
Dim strFilter As String
Dim strFolder As String
Dim strInputFileName As String

strFolder = "\\jsnet\drawingofficeintranet\zz publication order\"
strFilter = ahtAddFilterItem(strFilter, "PDF Files (*.PDF)", _
Me!SomeTextBox & "*.PDF")
strInputFileName = ahtCommonFileOpenSave( _
InitialDir = strFolder, _
Filter:=strFilter, OpenFile:=True, _
DialogTitle:="Please select an input file...", _
Flags:=ahtOFN_HIDEREADONLY)

End Sub


"Douglas J. Steele" wrote:

The implication is that somewhere in your application, you've declared
that
constant more than once.

Do a search through all your modules for Const ahtOFN_HIDEREADONLY

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"gymphil" <gymphil@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:B15D34C9-036A-447D-B889-8FC2D84CD6BC@xxxxxxxxxxxxxxxx
Doug

I have amended the code but I am getting a compile error:
Named argument already specified
ahtOFN_HIDEREADONLY

Any suggestions?



"Douglas J. Steele" wrote:

The ahtCommonFileOpenSave function has an optional InitialDir
parameter.

Dim strFilter As String
Dim strFolder As String
Dim strInputFileName as String

strFolder = "C:\Folder\Subfolder\"
strFilter = ahtAddFilterItem(strFilter, "PDF Files (*.PDF)", _
Me!SomeTextBox & "*.PDF")
strInputFileName = ahtCommonFileOpenSave( _
InitialDir = strFolder, _
Filter:=strFilter, OpenFile:=True, _
DialogTitle:="Please select an input file...", _
Flags:=ahtOFN_HIDEREADONLY)

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"gymphil" <gymphil@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:8D83F134-A902-4263-9036-7F73B02FABE4@xxxxxxxxxxxxxxxx
Sorry to be a pain, one further question - How can I direct the
search
to
look at a specific directory?

"gymphil" wrote:

Brilliant!

It works perfectly and is just want I wanted to achieve. The user
inputs
the
first few characters into the textbox and those pdf files are
displayed
for
selection, superb.

I sincerely appreciate your help and hope this information is
helpful
to
others.

Thanks again Doug





"Douglas J. Steele" wrote:

Sorry, but why? You've already got a way for them to select the
PDF
file of
interest: why do you need to use a combo box instead?

That being said, the dialog can limit those PDF files returned
based
on
the
first 6 characters typed into a text box named SomeTextBox if you
change the
filter to

strFilter = ahtAddFilterItem(strFilter, "PDF Files (*.PDF)",
Me!SomeTextBox
& "*.PDF")


--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"gymphil" <gymphil@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:B4769C3C-5E93-4391-952D-F037A3B82B5D@xxxxxxxxxxxxxxxx
Doug,

OK, I added the followhyperlink to the back of the code and it
is
now
opening the file I selected when prompted, great! Is it possibe
(rather
than
opening the whole directory) to just return the file (or files)
with
the
first 6 characters that the user types into a text box? I know
that I
cannot
use hyperlinks with wildcards and I cannot use AddItem in
Access
2000
with
a
list box, is there another way? Ideally I would like to add
these
files to
a
combo box or list box or subform so that the user can select
the
required
file and open the pdf document.
Also, the combo box currently is inactive! it does not store
the
string
variable.

Appreciate your help, I am still a novice!

"Douglas J. Steele" wrote:

You're absolutely right. All that code does is prompt the user
to
a
select a
file, and stores the full path to the selected file in a
variable
(strInputFileName).

All the code you had before was going to do was put the names
of
the
files
into a combo box. Once the user selected a file from that
combo
box,
nothing
was going to happen unless you did something with the
selection.

Assuming what you're trying to do is open the document in the
user's
default
application (Adobe Reader, FoxIt, whatever), try

Application.FollowHyperlink strInputFileName

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"gymphil" <gymphil@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:D348CA11-F33F-4C60-B4FC-C46924824DF3@xxxxxxxxxxxxxxxx
Doug,

Thanks, I believe I have done what you suggested.
Don't know if I am missing the obvious but basically using a
command
button
I am now prompted to open pdf files in a directory, I can
only
select
one,
but nothing happens!
What I am looking for is the user to input the first 6
characters
of
the
file name in a text field and somehow or another to view or
browse
those
files that begin with those characters, and to select the
required
file
to
open.

Apologies if I did not explain this properly.


"Douglas J. Steele" wrote:

Create a new module (not a class module nor a module
associated
with a
form
or report).

Copy everything in the shaded area (between Code Start and
Code
End)
into
that module.

When you save the module, make sure you don't name it the
same
as
any
subs
or functions in it. (calling it something like
mdlFileDialog
would
probably
be a good idea)

Where you want to invoke the dialog, use code like the
sample
at
the
top
of
the page. To find only PDF files, you'd use something like

Dim strFilter As String
Dim strInputFileName as String

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

strInputFileName will contain the complete path to the file
they
select.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"gymphil" <gymphil@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in
message
news:CE4E1712-4EA7-45FF-823E-C021C289D7AA@xxxxxxxxxxxxxxxx
Doug,

Thanks for your advise, I have had a look a the link you
gave
me,
not
sure
what to do with the code but I will try and work it out.

many thanks

"Douglas J. Steele" wrote:

As I mentioned else-thread, the AddItem method wasn't
introduced
until
Access 2002, so you won't be able to use that code.

Can you present them with the standard Windows File
Open/File
Save
dialog
instead? See http://www.mvps.org/access/api/api0001.htm
at
"The
Access
Web"
for a complete example.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"gymphil" <gymphil@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in
message
news:C46CC2BE-498F-43E3-A219-A4D0A51B9B0C@xxxxxxxxxxxxxxxx
Thanks for your prompt response.

I am using access 2000.

Basically I want to find files in a 'C' directory
using
data
from
a
control
on a form, but I need to combine this with a wild
card. I
initally
wanted
to
use hyperlinks but cannot use wildcards in hyperlinks,
so
I
want
to
extract
the file names and somehow add them to a list box or
perhaps
a
form
so
the


.


Loading