A
Arnold Klapheck
I am trying to get the proper error messages to display if the user left a
date field blank or did not put the date in proper format. I have the cell
formatted to short date and it shows the date in the proper format. Right now
when leave blank getting format error msg instead of blank error message.
any ideas?
Sub Verify_FPP_Info()
On Error GoTo Handler
Dim x As Integer
PName = Sheets("Program Controls").Range("F4").Value
RCID = Sheets("Program Controls").Range("F6").Value
BPrd = Sheets("Program Controls").Range("F8").Value
EPrd = Sheets("Program Controls").Range("F10").Value
AName = Sheets("Program Controls").Range("F12").Value
If PName = "" Then
x = MsgBox("You must enter a Participant Name", vbCritical, "Error")
Range("ParticipantName").Select
Range("ParticipantName").Activate
End
ElseIf RCID = "" Then
x = MsgBox("You must enter Participant's ID", vbCritical, "Error")
Range("ParticipantID").Select
Range("ParticipantID").Activate
End
ElseIf BPrd = "" Then
x = MsgBox("You must enter Period From Date", vbCritical, "Error")
Range("PeriodFrom").Select
Range("PeriodFrom").Activate
End
ElseIf EPrd = "" Then '*****starting here
x = MsgBox("You must enter a Period Thru Date", vbCritical, "Error")
Range("PeriodThru").Select
Range("PeriodThru").Activate
End
ElseIf BPrd > EPrd Then
x = MsgBox("The Thru Date must be after the From Date", vbCritical,
"Error")
Range("PeriodThru").Select
Range("PeriodThru").Activate
End
ElseIf AName = "" Then
x = MsgBox("You must enter an Auditor's Name", vbCritical, "Error")
Range("Auditor").Select
Range("Auditor").Activate
End
End If
Exit Sub
Handler: 'Get here means failure
Select Case Err.Number
Case 13
x = MsgBox("Make sure your dates are in the right format MM/DD/YY",
vbCritical, "Error")
Range("PeriodFrom").Select
Range("PeriodFrom").Activate
End
Case Else
Dim Msg As String
Msg = Err.Number & ":" & Err.Description
MsgBox Msg
End
End Select
End Sub
date field blank or did not put the date in proper format. I have the cell
formatted to short date and it shows the date in the proper format. Right now
when leave blank getting format error msg instead of blank error message.
any ideas?
Sub Verify_FPP_Info()
On Error GoTo Handler
Dim x As Integer
PName = Sheets("Program Controls").Range("F4").Value
RCID = Sheets("Program Controls").Range("F6").Value
BPrd = Sheets("Program Controls").Range("F8").Value
EPrd = Sheets("Program Controls").Range("F10").Value
AName = Sheets("Program Controls").Range("F12").Value
If PName = "" Then
x = MsgBox("You must enter a Participant Name", vbCritical, "Error")
Range("ParticipantName").Select
Range("ParticipantName").Activate
End
ElseIf RCID = "" Then
x = MsgBox("You must enter Participant's ID", vbCritical, "Error")
Range("ParticipantID").Select
Range("ParticipantID").Activate
End
ElseIf BPrd = "" Then
x = MsgBox("You must enter Period From Date", vbCritical, "Error")
Range("PeriodFrom").Select
Range("PeriodFrom").Activate
End
ElseIf EPrd = "" Then '*****starting here
x = MsgBox("You must enter a Period Thru Date", vbCritical, "Error")
Range("PeriodThru").Select
Range("PeriodThru").Activate
End
ElseIf BPrd > EPrd Then
x = MsgBox("The Thru Date must be after the From Date", vbCritical,
"Error")
Range("PeriodThru").Select
Range("PeriodThru").Activate
End
ElseIf AName = "" Then
x = MsgBox("You must enter an Auditor's Name", vbCritical, "Error")
Range("Auditor").Select
Range("Auditor").Activate
End
End If
Exit Sub
Handler: 'Get here means failure
Select Case Err.Number
Case 13
x = MsgBox("Make sure your dates are in the right format MM/DD/YY",
vbCritical, "Error")
Range("PeriodFrom").Select
Range("PeriodFrom").Activate
End
Case Else
Dim Msg As String
Msg = Err.Number & ":" & Err.Description
MsgBox Msg
End
End Select
End Sub