Open A Specific Directory Window (1 Viewer)

mstorer

Registered User.
Local time
Today, 13:27
Joined
Nov 30, 2001
Messages
95
I have a hyperlink field on my form. All of the files to which the hyperlinks point are located in a specific directory on our network. I would like the user to hit a command button (I.e. Link Report) that will open our designated directory directly, rather than have the users muddle their way through the network to find it.

My thought process, because it's the only way I know how, is something like the following:

Private Sub AddReport_Click()
DoCmd.GoToControl "Report"
SendKeys "%(I)I%(F){TAB 7}R {ENTER}", True
End Sub

Unfortunately, this gets me just shy of the directory I want and from what I've read here, using sendkeys is not a great way to go about things. I looked in the help files at the dir() command but don't think that will help. Any suggestions?

- Matt
 

dcx693

Registered User.
Local time
Today, 08:27
Joined
Apr 30, 2003
Messages
3,265
What do you want to happen when the users click this command button? Just open an Explorer window with the folder contents? Open a particular file?
 

mstorer

Registered User.
Local time
Today, 13:27
Joined
Nov 30, 2001
Messages
95
Thanks for the reply. Ideally, the command button would do the following:
Go To Control "Report"
DoCmd.RunCommand acCmdInsertHyperlink
Browse to the designated folder.

At that point the user would select the file they want from the directory. My problem is that I cannot "browse" to the designated folder. I come up short of the sub directory I want.

I was wondering if there was a way to take automatically the user to the designated folder after the insert hyperlink command so they won't have to browse the network for the directory. Hopefully I'm making more sense now. Thanks again for the help.
 
Last edited:

mstorer

Registered User.
Local time
Today, 13:27
Joined
Nov 30, 2001
Messages
95
Thanks for the help. I hadn't reaized that it would require so much coding. Since I am a relative dummy in VB and only partially understand all that is happening in this code, I'm unsure if this would actually work in my scenario....and it would take more time than I have to figure out how to make work. Thanks so much for your research though. I will toy with this and see if I could use it use it later.

- Matt
 

spacepro

Registered User.
Local time
Today, 13:27
Joined
Jan 13, 2003
Messages
715
This should work:

Call Shell ("explorer.exe c:\foldername",1)

Regards

Replace C: with network drive.


Andy
 

mstorer

Registered User.
Local time
Today, 13:27
Joined
Nov 30, 2001
Messages
95
Thanks Andy. Calling Explorer works well as I can take the user to our designated directory. However, I am still clueless as to how I can make Access recognize that I want to insert the selcted file into the hyperlink field. Calling Explorer allows me to open the file but not insert it as the hyperlink in the database. I have tried placing both InsertHyperlink and InsertFile before and after the Call statement. Doing that, unfortunately, opens their their own dialog box and I am essentially back where I started.

I guess there is no syntax that would do the following:

DoCmd.RunCommand acCmdInsertHyperlink c:\foldername

Where c:\foldername is the default location of the files.

In any event, thanks for help on this.

- Matt
 

spacepro

Registered User.
Local time
Today, 13:27
Joined
Jan 13, 2003
Messages
715
Add a microsoft dialog control to your form , then on the onlick event of the command button add the following code:

Me.CommonDialog3.InitDir = "C:\images"
Me.CommonDialog3.ShowOpen
Me.Text1 = CommonDialog3.FileName

I have posted an example, then onclick of the text box add the following:

application.followhyperlink me.text1.value

This will basically open the windows dialog with the specific directory then enter the selected file into the textbox as a hyperlink, then opens the file path when clicked upon.

See the attached db.
In the line whre C:\images is replace this with the folder path.

HTH

Andy
 

Attachments

  • hyperlink.zip
    9.3 KB · Views: 912

mstorer

Registered User.
Local time
Today, 13:27
Joined
Nov 30, 2001
Messages
95
Andy-

Brilliant approach! It works like a charm. I haven't experimented with the ActiveX controls before. Time to crack open my books and see what else one can do with them. Thanks again for your time and effort.

- Matt
 

Zanatos

New member
Local time
Today, 05:27
Joined
May 29, 2007
Messages
7
I'm confused.
I've been looking up this subject all day long, and everyone is constantly referencing VB code for the answer, but what if you don't want VB code to go through this process?
I have a database with a Hyperlink on it that updates as you move from file to file. Whenever you click on it it takes you to the directory that the file is located in without a problem. My only problem is that we want this hyperlink to open our file, not the directory. We're not sure how to make this work WITHOUT any VB code.

Does anyone know?
 

robsue38

New member
Local time
Today, 20:27
Joined
May 21, 2011
Messages
1
Me.CommonDialog3.InitDir = "C:\images"

HTH

Andy

Hi Andy, I tried your approach on my PC and it worked perfectly. I transferred it to another PC that also has MS Access 2007 and I get an error message on the line above - saying "object doesn't support this property or method" when I run it and when I open the file it says ""There is no object in this control". I have checked the references and both machines have the same references. Only difference is it works on the machine that has Windows 7 Home Premium with VBA version 6.5.1053 but won't work on the Windows XP Professional machine running VBA Version 6.5.1040 but I have no idea how to upgrade VBA versions (in case that is the problem). When I look at the commondialog object the one on the non-working machine has many less properties.

Do you have any suggestions as to what is missing?
 

Users who are viewing this thread

Top Bottom