How to open or point to a file using UNC format text box

D

Dave

Hello I have a access 07 frontend and sql server back end. I would like to
open a folder on my network that is associated to the file using network
path. \\ComputerName\SharedFolder\Resource instead of attaching the PDF
files into access due to database size constraints. Is there some code to do
this ? the txt box in access will underline when the path is typed in(like a
hyperlink), but it doesnt open the folder.
 
D

dymondjack

I haven't tested this, but I think it should be along the right direction.

Try using Shell or ShellExecute API to call the windows Explorer program (to
open a folder for viewing). A command line argument can be passed when
explorer is called to open to any particular folder (this is the Explorer.exe
argument, not shell).

I've seen this done in batch files many times, but don't remember the exact
syntax. If it can be done in a batch, there's no reason you can't pass that
same command via the access Shell function.

There's a whole myraid of command-line arguments for opening explorer...
everything from what you want visible in the right-hand bar to what folder
you want opened, hidden files visible, etc, etc.

I remeber reading a whole article on this a few months ago, but don't
remember where it was. Some fairly easy internetsearching should get you
some details though.


hth
--
Jack Leach
www.tristatemachine.com

- "First, get your information. Then, you can distort it at your leisure."
- Mark Twain
 
D

Dave

Dale,

I made the module ( i think) but when i click on either version of the
event procedure it gives me an error invalid outside procedure. This may as
well be russian.
here is the error:

Invalid outside procedure

The statement must occur within a Sub or Function, or a property procedure
(Property Get, Property Let, Property Set). This error has the following
cause and solution:


An executable statement, Static or ReDim, appears at module level.
Static is unnecessary at module level, since all module-level variables are
static. Use Dim instead of ReDim at module level. To create a dynamic array
at module level, declare it with Dim using empty parentheses.


Note
At module level, you can use only comments and declarative statements, such
as Const, Declare, Deftype, Dim, Option Base, Option Compare, Option
Explicit, Option Private, Private, Public, and Type. The Sub, Function, and
Property statements occur outside the body of their procedures, but within
the procedure declaration.



For additional information, select the item in question and press F1 (in
Windows) or HELP (on the Macintosh).
 
D

Dale Fye

Dave,

It looks like you put this at the top of the forms VBA window. It needs to
be in an event associated with a control. here is how to do this.

1. Open the form in design view.
2. Put your cursor in the textbox where the filename is located (I'll call
it txt_FileName for example purposes).
3. Open the properties Dialog and click on the event tab
4. At the top of the properties dialog you should see the name of the
control. Put your cursor in the DoubleClick event, drop down the list and
select "Event Procedure". Then click the "..." button to the right. This
will take you to the VBA code window, to the textboxes double click event,
which should look like:

Private Sub txt_FileName_DblClick(Cancel As Integer)

End Sub

Insert the code I provided in the space between the Private Sub and End sub
lines. It should look something like:

Private Sub txt_FileName_DblClick(Cancel As Integer)

Dim strPath as string
strPath = "\\ComputerName\SharedFolder\Resource\"
Application.Followhyperlink strPath & me.txt_FileName

End Sub

--
HTH
Dale

email address is invalid
Please reply to newsgroup only.
 
S

Stuart McCall

Dave said:
Hello I have a access 07 frontend and sql server back end. I would like
to
open a folder on my network that is associated to the file using network
path. \\ComputerName\SharedFolder\Resource instead of attaching the PDF
files into access due to database size constraints. Is there some code to
do
this ? the txt box in access will underline when the path is typed
in(like a
hyperlink), but it doesnt open the folder.

Place a command button next to your textbox and, in its OnClick event
procedure, put this code:

Application.FollowHyperlink Me.TextboxName

So if TextboxName contains:

\\ComputerName\SharedFolder\Resource

an explorer window will open, ready-navigated to the correct folder.
 

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