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

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
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.
 
Upvote 0

Forum statistics

Threads
1,215,219
Messages
6,123,683
Members
449,116
Latest member
HypnoFant

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