link to a pdf

  • Thread starter Thread starter rml
  • Start date Start date
R

rml

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.

Thanks.
 
You could make a table with all your Pdfs hyperlinked and then create a cbo
with the table as it's row source? This way they can select the PDF from the
cbo. It just a thought. Plus, you can easily update it as well.
 
rml said:
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 -----
 
That worked! Thanks.

Dirk Goldgar said:
rml said:
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)
 

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

Similar Threads


Back
Top