Consulting

Results 1 to 4 of 4

Thread: formatting a label

  1. #1

    formatting a label

    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

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]

    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
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3

    formatting a label

    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

  4. #4
    sorry missed of attached

    thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •