ipbr21054
Well-known Member
- Joined
- Nov 16, 2010
- Messages
- 5,726
- Office Version
- 2007
- Platform
- Windows
I have this code on a userform.
Sometimes when this form is opened the user sees an error so closes the form by pressing the Red Cross top right.
The code still runs.
Ive added a command button with Unload Me on it but code still runs.
How do i stop the code from running.
VBA Code:
Private Sub TransferInvNumber_Click()
ActiveCell.Value = TransferInvoiceNumber.TextBox1.Value
Unload Me
Const FILE_PATH As String = "C:\Users\Ian\Desktop\REMOTES ETC\DR\DR COPY INVOICES\"
If ActiveCell.Column = Columns("P").Column Then
If Dir(FILE_PATH & ActiveCell.Value & ".pdf") <> "" Then
ActiveCell.Hyperlinks.Add Anchor:=ActiveCell, Address:=FILE_PATH & ActiveCell.Value & ".pdf"
Else
ActiveCell.Hyperlinks.Delete
MsgBox (FILE_PATH & ActiveCell.Value & ".pdf" & vbNewLine & vbNewLine & "FILE IS NOT IN FOLDER SPECIFIED, PLEASE CHECK PATH IS CORRECT"), vbCritical
End If
Else
MsgBox "PLEASE SELECT AN INVOICE NUMBER.", vbExclamation, "HYPERLINKING THE INVOICE NUMBER"
End If
End Sub
Sometimes when this form is opened the user sees an error so closes the form by pressing the Red Cross top right.
The code still runs.
Ive added a command button with Unload Me on it but code still runs.
How do i stop the code from running.