PDA

View Full Version : formatting a label



northernstar
09-12-2007, 09:33 AM
hi everyone

i would like to format a label to a number of decimal places depending on the value of a textbox

decimalplaces is a textbox on a multipage form (page1)
corrected1 is a label on a multipage form (page2)

so when decimalplaces = 0

i would like corrected1 to be formatted to no decimal places (ie 1)

when decimalplaces = 1

and for corrected1 to one decimal places (ie 1.0)

etc

i have tried the following

private sub DecimalPlaces_Change()
if DecimalPlaces="1" then
Corrected1=Format(Corrected1,"0.0")
end if


i have tried the Format statement in other code and it works fine

any ideas

thanks

xld
09-12-2007, 09:43 AM
Private Sub decimalplaces_Change()
Dim str As String
With Me.decimalplaces
If IsNumeric(.Text) Then
If .Text > 0 Then
str = "." & Left("0000000000", .Text)
End If
Me.corrected1.Caption = Format(corrected1, "#,##0" & str)
End If
End With
End Sub

northernstar
09-12-2007, 02:18 PM
i have tried the code you suggested and the dropdown (from another thread) worked well

but i still cant get the labels to format as a number in the format say 0.00

i have attached a copy of the file and i would appreciate comments and advice on how to solve this and to improve the form

i have to repaeat the code for all the dropdowns

piston1 to piston11
units1 to units 11
etc

just wondering if there is another way?

look forward to recieving your comments and advice

many thanks

northernstar
09-12-2007, 02:22 PM
sorry missed of attached

thanks