ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Format text box with check box (https://www.excelbanter.com/excel-programming/436962-format-text-box-check-box.html)

Rachel

Format text box with check box
 
Hi,
I have a text box (txtphone) into which a user enters a phone number. The
default format of txtphone is "00-0000-0000". I also have a check box
(chkmobile) which I want the user to tick if the phone number is a mobile
number. When chkmobile is ticked I want the format of txtphone to change to
"0000-000-000" and then if it is unticked change back to default
"00-0000-0000". Make sense?
Currently I have:

Private Sub txtPhone_afterupdate()
If chkMobile.Value = False Then
txtPhone.Value = Format(Me.txtPhone.Value, "00-0000-0000")
End If
End Sub

Private Sub chkmobile_click()
If chkMobile.Value = True Then
txtPhone.Value = Format(Me.txtPhone.Value, "0000-000-000")
End If
End Sub

When I enter a number into txt phone currently and tab out the format
changes to the default but ticking chkmobile does nothing.

Any help is greatly appreciated.
Rachel

Rachel

Format text box with check box
 
Sorry - duplicated question. Already answered, I just couldn't find the
original post.
Thanks :)

"Rachel" wrote:

Hi,
I have a text box (txtphone) into which a user enters a phone number. The
default format of txtphone is "00-0000-0000". I also have a check box
(chkmobile) which I want the user to tick if the phone number is a mobile
number. When chkmobile is ticked I want the format of txtphone to change to
"0000-000-000" and then if it is unticked change back to default
"00-0000-0000". Make sense?
Currently I have:

Private Sub txtPhone_afterupdate()
If chkMobile.Value = False Then
txtPhone.Value = Format(Me.txtPhone.Value, "00-0000-0000")
End If
End Sub

Private Sub chkmobile_click()
If chkMobile.Value = True Then
txtPhone.Value = Format(Me.txtPhone.Value, "0000-000-000")
End If
End Sub

When I enter a number into txt phone currently and tab out the format
changes to the default but ticking chkmobile does nothing.

Any help is greatly appreciated.
Rachel



All times are GMT +1. The time now is 11:48 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com