LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #9   Report Post  
Posted to microsoft.public.excel.misc,microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Excel 97 - VB question

Yes, it worked. Thanks to you and everyone else who helped.

"Dave Peterson" wrote in message
...
This might work...

Option Explicit
Dim BlkProc As Boolean
Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If BlkProc = True Then Exit Sub
If IsNumeric(Me.TextBox1.Value) Then
MsgBox "nope"
Cancel = True
End If
End Sub
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If CloseMode = vbFormControlMenu Then
BlkProc = True
End If
End Sub


Old Car wrote:

Thank you for your suggestion. Yes, I use a message box to tell the

user
the content of textbox1 is invalid. I would prefer using a messsage box
rather than a label. Is there a way I can detect within textbox1_Exit

that
the window is being closed, and therefore the message box should not be
displayed?

"Dave Peterson" wrote in message
...
Are you using a msgbox to tell the user that the textbox is invalid?

If
yes,
maybe you could move that message to a label right near the textbox.

If the user closes the userform, the label gets updated, but it's

pretty
quick
and probably not noticeable. But the good thing is that it won't

disturb
the
user with another msgbox.

Old Car wrote:

Thanks. Using that technique, I find that closing the window

causes
that
event to fire. Is there a way to test for the fact that the Exit

event
is
firing because a "Close" button is being selected?

"Patrick Molloy" wrote in

message
...
you can use the textbox's Exit event...

Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If TextBox1.Text = "X" Then
Cancel = True
End If
End Sub

"Old Car" wrote:

I have a form with some textboxes on it (textbox1 and textbox2).

When
the
user tabs from textbox1 to the textbox2, I validate the contents

of
the
textbox1 in the textbox1_AfterUpdate event handler. If the

content
textbox1
is invalid, I want to keep the cursor in textbox1, rather than

tabbing
to
textbox2.

I have tried using textbox1.SetFocus method in the

textbox1_AfterUpdate
and
textbox2_Enter event handlers. Neither worked.

What is a good way to do this? Thanks.




--

Dave Peterson


--

Dave Peterson



Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"