Access 2007 hyperlink field will not work

Posted on 2009-02-19
Medium Priority
Last Modified: 2012-06-27
Hello.  I wrote a program in  VBA that inserts the path to several files into a hyperlink field in a Access 2007 table.  The program works, but the hyperlinks don't.  When I copy one of the paths inserted by the program to another record, it gets pasted with two hash (#) symbols at the end.  If I eliminate the symbols, the hyperlink works without a problem.  Here's an example:

Original hyperlink:


After pasting:


The funny thing is that I don't find the hashes in the paths originally inserted by the program, only after I paste them.  Anything I should implement in the code (see snippet)  that will get the hyperlinks working right away? Thanks!

Dim recSet As ADODB.Recordset
Dim value1 As String
Dim value2 As String
Dim fsObject As Object
Dim myFolder As Object
Dim strSQL As String
Dim fileObj As Object
Sub LinkFile()
    ' Gets path name
     myPath = InputBox("Enter full path.")
     value1 = InputBox("Enter criterion 1.")
     value2 = InputBox("Enter criterion 2.")
    ' Makes a new file system object.
    Set fsObject = CreateObject("Scripting.FileSystemObject")
    ' Gets the FSO Folder (directory) object.
    Set myFolder = fsObject.GetFolder(myPath)
    ' Gets a reference to the current database
    Set conDB = CurrentProject.Connection
    ' Makes the list of file names
    ReDim myFiles(1 To myFolder.Files.Count) As String
    For Each myEachfile In myFolder.Files
	' Gets record set and queries database
        Set recSet = New Recordset
        strSQL = "Select * FROM table WHERE field1='" & value1 & "' AND field2='" & value2 & "';"
        recSet.Open strSQL, conDB, adOpenDynamic, adLockOptimistic
        recSet!HyperlinkField = myEachfile
    Set recSet = Nothing
    Set conDB = Nothing
End Sub

Open in new window

Question by:taioba
1 Comment
LVL 58

Accepted Solution

harfang earned 500 total points
ID: 23687455
A hyperlink in Access is a memo field with special treatment. The link is stored in this format:

    text to display#URL#subaddress

So you could store this for example:

    link to Myfile.ext#file:///C:/MyFolder/Myfile.ext#

Good luck!

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
Sometimes MS breaks things just for fun... In Access 2003, only the maximum allowable SQL string length could cause problems as you built a recordset. Now, when using string data in a WHERE clause, the 'identifier' maximum is 128 characters. So, …
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question