ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Formatting text box (https://www.excelbanter.com/excel-discussion-misc-queries/13179-formatting-text-box.html)

Doug Loewen

Formatting text box
 
I have 3 text boxes on a form and a label that show the
sum of the 3. How do I format the text boxes and label so
it shows currency. If user enters 123 I want it to
display as $ 123.00 in the text box and in the label.
Thanks for your help

CyberTaz

Is this an Excel question or an ACCESS question?

If Access, select the text boxes in the form's Design View and choose
Currency from the Format page of the Properties window.

If not Access, please explain what you mean by "text boxes" & "labels" |:)

"Doug Loewen" wrote:

I have 3 text boxes on a form and a label that show the
sum of the 3. How do I format the text boxes and label so
it shows currency. If user enters 123 I want it to
display as $ 123.00 in the text box and in the label.
Thanks for your help


Dave Peterson

Maybe something like this:

Option Explicit
Dim BlkProc As Boolean
Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim myStr As String
With Me.TextBox1
If IsNumeric(.Value) Then
BlkProc = True
myStr = Format(.Value, "$ ##0.00")
.Value = myStr
Me.Label1.Caption = myStr
BlkProc = False
End If
End With
End Sub



Doug Loewen wrote:

I have 3 text boxes on a form and a label that show the
sum of the 3. How do I format the text boxes and label so
it shows currency. If user enters 123 I want it to
display as $ 123.00 in the text box and in the label.
Thanks for your help


--

Dave Peterson

Dave Peterson

You can have userforms in excel, too!



CyberTaz wrote:

Is this an Excel question or an ACCESS question?

If Access, select the text boxes in the form's Design View and choose
Currency from the Format page of the Properties window.

If not Access, please explain what you mean by "text boxes" & "labels" |:)

"Doug Loewen" wrote:

I have 3 text boxes on a form and a label that show the
sum of the 3. How do I format the text boxes and label so
it shows currency. If user enters 123 I want it to
display as $ 123.00 in the text box and in the label.
Thanks for your help


--

Dave Peterson

Dave Peterson

I set up a boolean variable and never used it!

Option Explicit
Dim BlkProc As Boolean
Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim myStr As String
if blkproc = true then exit sub
With Me.TextBox1
If IsNumeric(.Value) Then
BlkProc = True
myStr = Format(.Value, "$ ##0.00")
.Value = myStr
Me.Label1.Caption = myStr
BlkProc = False
End If
End With
End Sub

To stop the code from running itself.


<<snipped


All times are GMT +1. The time now is 04:26 AM.

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