You are here:

Using MS Access/Command button to open file


Hi Scott,

Just a quick question.  How do I program a command button to open a file on a networked drive?  The file on the neworked drive has the same name as my record ID.  So the file I am trying to open is relevant to current record on the form.  I can get this to work if the file I am looking to open is on the same drive, but it does not work if the file is located on another drive.  Thanks for any help you can provide me with this.  It is very much appreciated as always. Carla

This is what I have so far that seems to work using one drive...

Private Sub Command169_Click()
Dim strFilename As String
strFilename = "C:\FOLDER\" & Format([PO_ID], "000000") & ".pdf"
Application.FollowHyperlink strFilename
End Sub

Well you need to know where it is. Your code is correct, but you have to substitute the actual path for C:\Folder.

If different PCs have different drive mappings (letters), you can use UNC codding:

strFilename = "\\servername\sharename\foldername\" & Format([PO_ID], "000000") & ".pdf"

Hope this helps,
Microsoft Access MVP 2007
Author: Microsoft Office Access 2007 VBA

Using MS Access

All Answers

Answers by Expert:

Ask Experts




I can answer almost all types of questions relating to Microsoft Access usage and application design. My strengths are database and interface design.


I've been designing databases for over 25 years working with dBase, FoxPro, Approach and Access.

Author of Microsoft Office Access 2007 VBA
Techncial Editor for Special Edition Using Microsoft Access 2007 and Access 2007 Forms, Reports & Queries From Que Publishing

Brooklyn College BA

©2017 All rights reserved.