Formatting text box

  • Thread starter Thread starter Doug Loewen
  • Start date Start date
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
 
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" |:>)
 
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
 
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" |:>)
 
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>>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top