Display Contents of Hyperlinked Object in a Report

C

Clifford Bass

Hi All,

I have a hyperlink field in a child table in an Access 2003 database
which will be used to point to electronic invoice files stored on a network
drive. These files could be BMP, JPG, TIF, Word, PDF, Excel, and who knows
what else. The table structures in brief are:

tblWORK_ORDERS
REQUEST_NUMBER
DESCRIPTION
...

tblWORK_ORDER_CHARGES (services done by outside contractors)
REQUEST_NUMBER
SEQUENCE_NUMBER
...
VENDOR_INVOICE_FILE (hyperlink field)

When printing work order report, I would like to include the actual
files listed in the hyperlinks in the child table in the report. I set up a
test report with a Bound Object Frame, but did not bind it. Following some
of the information in help I ended up with this code which it seemed to imply
was what would do the trick.

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)

Dim fso As New FileSystemObject
Dim strClass As String
Dim strFileExtension As String

strFileExtension = fso.GetExtensionName( _
[txtVENDOR_INVOICE_FILE].Hyperlink.TextToDisplay)

Select Case strFileExtension
Case "bmp", "jpg", "jpeg"
strClass = "Paint.Picture"
Case "doc", "docx"
strClass = "Word.Document"
Case "pdf"
strClass = "AcroExch.Document"
Case "xls", "xlsx"
strClass = "Excel.Sheet"
End Select
With [OLEBound12]
.Class = strClass
.OLETypeAllowed = acOLELinked
.SourceDoc = CurrentProject.Path & "\" & _
[txtVENDOR_INVOICE_FILE].Hyperlink.TextToDisplay
.Action = acOLECreateLink
.SizeMode = acOLESizeZoom
End With

End Sub

Needless to say, it does not. I get a runtime error of 2793:
"[Database] can't perform the operation specified in the Action property of
the Visual Basic procedure you're trying to run.".

Anyone out there know how to get this to work? Or if there is
another/better way that does work?

Thanks in Advance!

Clifford Bass
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top