View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Minitman[_4_] Minitman[_4_] is offline
external usenet poster
 
Posts: 273
Default Error Handling Problem

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