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
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