Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 96
Default Form Exit Event

In my macro, a form displays a textbox, radio buttons, and
push buttons. The textbox is populated with a phone
number. Sometimes the user will keep the existing number
(which is already formatted) and sometimes they will
change it.

I use the following code to format the textbox:

Private Sub TextBox3_Exit(ByVal cancel As
MSForms.ReturnBoolean)

If Not IsNumeric(TextBox3) Or Len(TextBox3) 10 Then
cancel = True
Me.TextBox3.Text = Format(TextBox3, "000-000-0000")

End Sub

I would like the users to be able to tab through the
form. The problem is they can tab through it until they
get to the text box. The tab is locked until they key in
a phone number.

What I would like to do is let the user tab through the
phone number if they keep the existing number and not
change it. If they change it and keep in 10 new number,
then it should be formatted automatically for them like it
does now. Any suggestions on how we can do this? Thanks
for the help.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default Form Exit Event

Maybe...

Option Explicit
Private Sub TextBox3_Exit(ByVal cancel As MSForms.ReturnBoolean)

If (Me.TextBox3.Value Like "###-###-####") Then
'ok, do nothing
ElseIf Not IsNumeric(Me.TextBox3.Value) _
Or Len(Me.TextBox3.Value) 10 Then
cancel = True
End If

Me.TextBox3.Value = Format(me.TextBox3.value, "000-000-0000")

End Sub

(I like the me. and .value)



JT wrote:

In my macro, a form displays a textbox, radio buttons, and
push buttons. The textbox is populated with a phone
number. Sometimes the user will keep the existing number
(which is already formatted) and sometimes they will
change it.

I use the following code to format the textbox:

Private Sub TextBox3_Exit(ByVal cancel As
MSForms.ReturnBoolean)

If Not IsNumeric(TextBox3) Or Len(TextBox3) 10 Then
cancel = True
Me.TextBox3.Text = Format(TextBox3, "000-000-0000")

End Sub

I would like the users to be able to tab through the
form. The problem is they can tab through it until they
get to the text box. The tab is locked until they key in
a phone number.

What I would like to do is let the user tab through the
phone number if they keep the existing number and not
change it. If they change it and keep in 10 new number,
then it should be formatted automatically for them like it
does now. Any suggestions on how we can do this? Thanks
for the help.


--

Dave Peterson

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Capture event when exit Column G zSplash Excel Discussion (Misc queries) 2 December 27th 04 05:28 PM
mouse move and exit event Shrinu Excel Programming 0 May 27th 04 01:09 AM
combobox exit event Dave D[_3_] Excel Programming 0 April 28th 04 10:22 PM
Exit Event Michael J. Malinsky Excel Programming 1 February 27th 04 06:40 PM
Control Exit event Fred Excel Programming 0 November 19th 03 12:59 AM


All times are GMT +1. The time now is 06:05 PM.

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

About Us

"It's about Microsoft Excel"