View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Bob Phillips Bob Phillips is offline
external usenet poster
 
Posts: 10,593
Default Private Textbox Exit Sub question...

I agree it looks nicer, but MsgBox does have an advantage, it slaps you
awake!



"Dave Peterson" wrote in message
...
But I think it looks nicer than a msgbox when there really is an error.

So maybe a combination of your flag that stops the label from being
updated
would be less of a kludge--but way more work <vbg.



Bob Phillips wrote:

Dave, that is so kludgy I am surprised at you <g

Bob

"Dave Peterson" wrote in message
...
Another option would be to use a label on the form instead of the
msgbox.

Then you could populate that label (red font??) when there's an
error --
or
clear it when it's ok.

And I bet no one would notice the error flashing by when the userform
closes.

wrote:

Hello all,

I have a Private Exit Sub for a Textbox that forces a person to enter
information in this box FIRST, before clicking into other parts of the
form. Basically, it's an employee time tracking form, and I've done
it this way because after they enter their employee number to start
off, it then goes up against another spreadsheet to bring back how
many vacation hours they have accrued to use up for the year. So this
way, they have to enter their number first in order to show what they
have, otherwise they have no business clicking around in other fields
and yada yada yada

Anyway, the question/problem I have is this: Once the userform is
displayed, I have part of the "verification" checking to see if they
left that textbox blank, and if they did it's shows a MsgBox that
says,

"Employee number field cannot be left blank. Please enter a valid
number."

Which works just fine, but if they click the "X" in the corner of the
userform to exit, it closes the form (which is what it's supposed to
do), but then because they left the textbox blank, after the forms
closes it still shows the message box telling them that the employee
field cannot be left blank.

Is there a way in the Private Exit Sub to specify, that IF the person
is "exiting" the textbox by clicking on the "X" to close, then not to
display the MsgBox?

Something like:

Private Sub EmpNum_Exit(ByVal Cancel As MSForms.ReturnBoolean)

If EmpNum.Value = "" AND (Close Button is Clicked) Then
(Close UserForm without MsgBox)
Else
MsgBox "Employee number field cannot be left blank. Please
enter a valid number."
End If

End Sub

--

Dave Peterson


--

Dave Peterson