Hyperlinks in Access Table

We currently have a hyperlink field in a Microsoft Access 2013 Table.  

To populate the field, we have the following code:

    Dim filesys
    Dim FromPath1 As String
    Dim ToPath1 As String
   
       
    If Len(Dir("T:\Completed Jobs Library - New System\" & [QuoteID], vbDirectory)) = 0 Then
        FromPath1 = "T:\Completed Jobs Library - New System\Master Job Folder"
        ToPath1 = "T:\Completed Jobs Library - New System\" & [QuoteID]
        Set filesys = CreateObject("Scripting.FileSystemObject")
        filesys.CopyFolder Source:=FromPath1, Destination:=ToPath1
       
    End If
   
    Me.DocumentLink = "C:\Completed Jobs Library - New System\" & [QuoteID]


I then have an on click event for the field on the form:
    If Me.DocumentLink Is Not Null Then
        Shell "C:\WINDOWS\explorer.exe """ & Me.DocumentLink & "", vbNormalFocus
    End If

I placed this on the server and now we receive the following error(See Attached "Error on Server")

Thoughts?
Error-on-Server.png
btgtechAsked:
Who is Participating?
 
PatHartmanCommented:
I'm not sure what "this" is.  Are you running the app on the server?

I don't use the Hyperlink data type because it cannot be upsized.  It violates first normal form since it mushes multiple attributes into a single column.  I use regular text data types and then in code use the FollowHyperlink method.  The advantage of this is that as long as you are linking to a registered file type, Windows will open the correct application.  With shell, you not only need to know what .exe you need to run, you also need to know where it is and that can be problematic in an environment where everything is not identical.  The downside is that you don't get to substitute descriptions for the actual file name.  Also, for certain types of links such as files associated with specific customers or audits, etc, I frequently define a path for the files in a different table.  So for example, in one app that manages insurance audits, I have a separate path for each audit and so the Audit table is where that is stored.  In another app, I keep documents for clients so the path for each client is stored in the client record.  That way, when I log the document I only need to store the actual file name.  This makes it pretty easy to move the folders around if necessary.

strTemp is populated with whatever the link is.  It could be a file name for a document stored on your server or it could be the name of a web page.  Anything valid as a link will work.
Application.FollowHyperlink strTemp
0
 
btgtechAuthor Commented:
This is a button within a form on in an Access app on a server.

The button is intended to create the directory to save the job documentation to.

There is already a master folder which we are making a copy of in the code and then assigning the link to the hyperlink field.

I will definitely try the FollowHyperlink method.

Thanks
0
 
Jeffrey CoachmanMIS LiasonCommented:
It looks like yo are creating a string value anyway,...
So I don't see the need to store this in a hyperlink field.
...also I am not sure what that large block of If/Then code is doing at the top of your code...

FWIW, your code works fine for me "as is"
...are you sure you code is generating a valid string/Path?

Try displaying the value in a message box:
 If Me.DocumentLink Is Not Null Then
        msgbox Me.DocumentLink
        'Shell "C:\WINDOWS\explorer.exe """ & Me.DocumentLink & "", vbNormalFocus
 End If

JeffCoachman
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.