Hi
I have a Error Handling routine that is not working. Could someone please have a look and see where I went wrong.
Basically, when the error occurs it does what it is supposed to do which is display message box, focus and clear text box. However, when there is not an error the main code executes the way it should but still displays the error message box.
Thanks
![]()
Private Sub cmdSearch_Click() On Error Goto ErrHandler If Me.txtPID.Value = "" Then MsgBox "Please enter ID.", vbCritical Me.txtPID.SetFocus Exit Sub End If lblName = Application.VLookup(CLng(txtPID.Value), Worksheets("Lists").Range("M:P"), 2, 0) lblStat = Application.VLookup(CLng(txtPID.Value), Worksheets("Lists").Range("M:P"), 4, 0) lblGender = Application.VLookup(CLng(txtPID.Value), Worksheets("Lists").Range("M:P"), 3, 0) lblRef = txtPID.Value & Format(txtDate.Text, "ddmm") & Application.VLookup(cboTime.Value, Worksheets("Lists").Range("F:G"), 2, 0) Exit Sub ErrHandler: MsgBox "Not a current ID. Please try again!", vbCritical txtPID.Value = "" Me.txtPID.SetFocus End Sub











LinkBack URL
About LinkBacks
Register To Reply

Click the * Add Reputation below to say thanks. 
Bookmarks