Formatting text box

D

Doug Loewen

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
 
C

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" |:>)
 
D

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
 
D

Dave Peterson

You can have userforms in excel, too!


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" |:>)
 
D

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>>
 
Top