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.
 

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

Back
Top