Link to a file or folder from an Access Form (1 Viewer)

worldcert

Registered User.
Local time
Today, 07:46
Joined
Jan 12, 2006
Messages
13
Hi Di Hi

I am new to Microsoft Access and have a little problem. I have searched the forum and nearly found the fix but I didnt quite understand what to do, so im creating a new thread.

I have a Access Database and have a client page that stores all the information about that client. We produce reports (scanned word/pdf) for each client and we store the report files in a client folder using the Client ID taken from Access.

My question is can I somehow produce a link from the Client Form in Access to the Client Folder or Files in explorer. I have seen the Hyperlink option but that is only availabe in Design View.

Hope someone can help. Thanks in advance,.
 

ScottGem

Registered User.
Local time
Today, 10:46
Joined
Jun 20, 2005
Messages
1,119
Can you explain more about what you want this link to do?
 

worldcert

Registered User.
Local time
Today, 07:46
Joined
Jan 12, 2006
Messages
13
Basically if a client ID is 9500 on Access then I will have a folder on the computer like c:\WCS\Clients\9500

I would like a link on the Access Form for client 9500 to either open a file in the client folder or open the folder to browse all the files.

Cheers
 
Last edited:

Hayley Baxter

Registered User.
Local time
Today, 14:46
Joined
Dec 11, 2001
Messages
1,607
The following code will open the folder of your choice in Explorer

Code:
Private Sub cmdExplore_Click()
On Error GoTo Err_cmdExplore_Click

Dim stAppName As String

stAppName = "C:\WINNT\explorer.exe c:\MyFolder"
Call Shell(stAppName, 1)

Exit_cmdExplore_Click:
Exit Sub

Err_cmdExplore_Click:
MsgBox Err.Description
Resume Exit_cmdExplore_Click

End Sub

Alternatively you can create a field in your table to hold the path of the filename you want it to link to. As long as this field is present on your form, you will be able to select the link to take you to the document directly.

Hay
 

ScottGem

Registered User.
Local time
Today, 10:46
Joined
Jun 20, 2005
Messages
1,119
There is code in the API section at www.mvps.org/access that will allow you to open the standard Windows file open dialog. You can set the default folder to open based on the client ID.
 

worldcert

Registered User.
Local time
Today, 07:46
Joined
Jan 12, 2006
Messages
13
Thanks for all the replys. I have kind of fixed my problem. I went to the form, entered design view, created a command button, event procedure and entered the code

On Error GoTo Err_cmdExplore_Click

Dim stAppName As String

stAppName = "C:\Windows\explorer.exe Z:\WCS\Clients\"
Call Shell(stAppName, 1)

Exit_cmdExplore_Click:
Exit Sub

Err_cmdExplore_Click:
MsgBox Err.Description
Resume Exit_cmdExplore_Click

End Sub

This opens explorer in the clients folder. However this doesnt get me direct in to the individual client folder so I still have to do a little bit of browsing to get to the right client.
 

ScottGem

Registered User.
Local time
Today, 10:46
Joined
Jun 20, 2005
Messages
1,119
us e

stAppName = "C:\Windows\explorer.exe Z:\WCS\Clients\" & Me.txtClientID & "\"

where txtclientID is the name of the control holdiing the clientID.
 

ghudson

Registered User.
Local time
Today, 10:46
Joined
Jun 8, 2002
Messages
6,195
Why are you opening Windows Explorer just to allow the user the ability to view the files? You can easily do that within Access [as my sample I mentioned above does] and give the user the option to open, link, print, etc the selected file or directory.
 

worldcert

Registered User.
Local time
Today, 07:46
Joined
Jan 12, 2006
Messages
13
Hi ghudson,

I had a look at your thread and link about browsing. Im not that good with access coding and it all looked a bit complicated so I went with the simple code. When I get a bit more time I will have another try. Cheers
 

MarkPl

New member
Local time
Today, 10:46
Joined
Aug 13, 2007
Messages
3
I am trying to do the same thing and I know that I am making a mistake someplace (since it isn't working) but I am not sure where. Can anyone tell from the code below what I am doing wrong?
//START CODE//
Private Sub btnOpenFldr_Click()
Dim CARPath As String
CARPath = "O:\ISO 9001\CARS\2007\" & Me.txtCarID.Value

Shell "C:\WINDOWS\EXPLORER.EXE " & CARPath & "\"
End Sub
//ENDCODE//
The other part to this is creating the folders for the CARs which it is doing properly, this however is just making me nuts. Any help would be appreciated.
Thanks, Mark
 

PearlEdwards

New member
Local time
Today, 07:46
Joined
Oct 6, 2013
Messages
1
So, thanks to you guys, I have now created a command button that opens windows explorer. I copied and pasted the snippet of code shown above and changed the file paths, control names and such to fit my own specs.

This command button does not, on the other hand, open a specific file in windows explorer based on the value of a field in my form. I'm a total newbie, so I'm certain it's my fault somehow.

This is the on-click event procedure I attempted to add to my command button...

Private Sub Command239_Click()
On Error GoTo Err_cmdExplore_Click

Dim stAppName As String

stAppName = "C:\Windows\explorer.exe C:\filepath\filepath\etc" & Me.ItemID & "\"
Call Shell(stAppName, 1)

Exit_cmdExplore_Click:
Exit Sub

Err_cmdExplore_Click:
MsgBox Err.Description
Resume Exit_cmdExplore_Click

End Sub

"filepath\filepath\etc", btw, is where I have my whole long file path in real life. Didn't figure anyone actually cared to see it.

Hrm.

Well, if you can imagine a reason why this would be happening, but you need some clarification, please just ask. There are sooo many possible little things I could have gotten wrong, settings wise or otherwise, it'd be insane to post every single thing up front.

Thanks for your help!
 

Users who are viewing this thread

Top Bottom