Re: link to a pdf

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



"rml" <rml@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:934D672F-5CB7-493F-B1B8-F78D13386973@xxxxxxxxxxxxxxxx
How can I create a command button that would open or link to a pdf depending
on the Part Number field value?

If Part Number equals abc123 then open abc123.pdf, if no corresponding pdf
exists, then display some text , "not available". The pdf would be located
in the c:\drawings folder.


For example:

'----- start of (untested) example code -----
Private Sub cmdViewPDF_Click()

Dim sPartNo As String
Dim sPDFName As String
Const conDrawingFolder As String = "C:\Drawings\"

sPartNo = Me![Part Number] & vbNullString

If Len(sPartNo) = 0 Then
MsgBox "There's no current part number!"
Else
sPDFName = conDrawingFolder & sPartNo & ".pdf"
If Len(Dir(sPDFName)) = 0 Then
MsgBox "No drawing is available for this part."
Else
Application.FollowHyperlink sPDFName
End If
End If

End Sub
'----- end of example code -----

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)

.


Quantcast