Thanks to Adezii's excellent article http://bytes.com/topic/access/answer...ink-into-table I can manage to create a hyperlink to the document and store it in the table, but it is the full hyperlink path not the reference number of the document that is displayed.
I have a workaround at present, where I have overlaid a second textbox [HCaption] over the one holding the hyperlink [Hlink]. If I type my document reference into [HCaption] box, then click the command button I can programatically add the 'caption' to the selected item to create the hyperlink, by modifying Adezii's code as below.
Expand|Select|Wrap|Line Numbers
- If .Show Then
- For Each varItem In .SelectedItems 'There will only be 1
- 'Replaced the original code marked with *, with this
- 'to produce different Caption and Address
- Me!Hlink = Me!HCaption & "#" & varItem
- ''*Caption and Address of Hyperlink will be the same (Caption#Address)
- '*strHyperlinkFile = varItem & "#" & varItem
- '*Me!Hlink = strHyperlinkFile
- Next varItem
- End If
I should add, I spent some time using just the [Hlink] text box and trying to enter the caption directly into that but Access seems to append 'http:\' or whatever, depending where the target is, and it does not work.
On the up-side, not all documents are scanned and available via a hyperlink and this is clear because they show as black text rather than blue underlined text. But I would welcome any comments on how to improve this.
The massive advantage of a hyperlink is that the document can be in any format that the default browser can interpret, so you don't have to read the file extension to know what program to shell out to.