Thread: UserForm
View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
jseven jseven is offline
external usenet poster
 
Posts: 32
Default UserForm

What I think you're doing....
1. You have a userform you created that has a button or two that checks
textboxes where you want folks to entere dates. If they entere dates
that are not valid, you pop up a message box to tell them. THE PROBLEM
is that once they click thorugh the message box, the form is blanked
out or unloaded or you just can't see it.

What I think you want to do....
A. Warn them
B. Don't dump the form

Get rid of the code "call main program"

All you need to do is run the code to check if it is a date or not then
pop the msgbox. Nothing else.



If you don't really care what info they put in there and just want to
warn them, highlight the text box when the exit the box.
Something like this:
Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If IsDate(TextBox1.Value) = False Then
TextBox1.BackColor = &HFF&
Else
TextBox1.BackColor = &HFFFFFF
End If
End Sub

if you really want to force them to enter the date appropriately,
(assuming you have a final button or routine they click to save their
entry....) just enter a snip of code in the routine that goes something
like this...

sub savebutton_click()
Dim DateFlag As Boolean
If IsDate(TextBox1.Value) = False Then DateFlag = True
If IsDate(TextBox2.Value) = False Then DateFlag = True
If IsDate(TextBox3.Value) = False Then DateFlag = True

If DateFlag = True Then
MsgBox "You need to enter the right date in the red boxes":
Exit Sub
End If
end sub

=====
Regards,
Jamie