Formatting User Form Display

Joe Glenn

New Member
Joined
Nov 7, 2005
Messages
2
I have created a user form that receives its value from a NameRange in the workbook.

Private Sub UserForm_Initialize()

tb_TFR_PM_3PH_AMT.ControlSource = "TFR_PM_3PH_AMT"
tb_TFR_PM_3PH_AMT.Text = Format(tb_TFR_PM_3PH_AMT.Text, "#,##0.00")
MsgBox "Value = " & tb_TFR_PM_3PH_AMT.Text & " ."

End Sub

When the MsgBox displays the value is formatted correctly but when it displays on the UserForm it is 8156.5.

How can I display the number correctly on the UserForm?
Excel 2007 Windows XP
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).

Joe Glenn

New Member
Joined
Nov 7, 2005
Messages
2
For all those individuals that have view this request this is how I finally solved the problem.

It boils down to where you put the Format command. I found that it works when you put the code on the textbox AfterUpdate sub.

Private Sub tb_AFUDC_AfterUpdate()
tb_AFUDC.Value = Format(Val(tb_AFUDC.Value), "###,###.##")
End Sub

The problem then becomes updating the database. The Val command stops read the data at the first comma. So instead of sending 6,500.00 to the database it sent 6. This is also a problem when trying to add two textbox values together to send to the database.

My solution to this problem was to create a variable as double in the sending routine and pass the variable instead of the text box.

Dim AFUDC As Double
AFUDC = tb_AFUDC.Value
Cells(LastRow, 20).Formula = CorpCap + AFUDC

Oh, isn't this more fun than Suduko.
 

Watch MrExcel Video

Forum statistics

Threads
1,132,671
Messages
5,654,655
Members
418,146
Latest member
Shnn028

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top