pdf link

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

rml

I'm using the following code to try and open a pdf file if the New2 is equal.
Example: If in the new2 field the value was 12345 you would click the
command button and if 12345.pdf exists then open, if not then some message.

Is the code below correct? When I click the button nothing happens?

Thanks.


Private Sub cmdViewPDF_Click()

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

sPartNo = Me![New2] & 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
 
It looks okay. Are you sure it's actually running? Make sure that the On
Click property for the button is set to [Event Procedure]. If it is, click
on the ellipsis (...) to the right, and make sure you get taken into that
code in the VB Editor.
 
Back
Top