View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default Error Handling Problem

That is what I guessed, so I would re-suggest my previous answer.

Private Sub TB1_Exit(ByVal Cancel As MSForms.ReturnBoolean)

On Error Resume Next
myDate = CDate(TeB1.Text)
If myDate = 0 Then
MsgBox "Error"
Cancel = True
Else
TB1.Text = Format(DateValue(TB1.Text), "mmm dd, yyyy")
End If

I am not seeing why it causes a debug, but hopefully this would avoid it.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Minitman" wrote in message
...
Hey Bob,

I guess I was to vague in my description. Then entry in TB1 is a date
which is formatted at exit to mmm dd, yyyy from mm/dd/yy. It is at
exit that an error will cause the problem.

The code in question looks like this:

Private Sub TB1_Exit(ByVal Cancel As MSForms.ReturnBoolean)

'Deposit Date

TB1.Text = Format(DateValue(TB1.Text), "mmm dd, yyyy")
.
.
.
End Sub

As I said earlier, if the person entering the dates mangles the date
so that it is not a date, They get an error to press either "use
debug" or "OK". "OK" takes them out of the form and back to the
worksheet. Debug will also get you there, only longer.

Anybody have any ideas?

TIA

-Minitman



On Sun, 14 Nov 2004 20:10:07 -0000, "Bob Phillips"
wrote:

Without seeing the code and knowing where the error generates, it is
difficult to be sure, but could you not cast the text into a date, and

if
the date is invalid it will error at that point which you can trap,
something like

On Error Resume Next
myDate = CDate(Textbox1.Text)
If myDate = 0 Then
MsgBox "Error"
End If