Results 1 to 7 of 7
  1. #1
    Join Date
    Jan 2004
    Location
    South Africa
    Posts
    178

    Question Unanswered: changing caption of a label

    how do i change the caption of a Label?
    I've tried:
    me.Label.caption = "Input"
    and while it does change the caption of the label on the screen, it doesn't change the caption in properties.
    i use 'IF' statements to check the caption of the label and then do something depending on what the label says.
    the caption in properties stays the same, so
    IF me.Label.Caption
    is always true.

    pls help
    thanks in advance

  2. #2
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713

    Re: changing caption of a label

    Originally posted by actionant
    how do i change the caption of a Label?
    I've tried:
    me.Label.caption = "Input"
    and while it does change the caption of the label on the screen, it doesn't change the caption in properties.
    i use 'IF' statements to check the caption of the label and then do something depending on what the label says.
    the caption in properties stays the same, so
    IF me.Label.Caption
    is always true.

    pls help
    thanks in advance
    WHAT???

    IF me.Label.Caption
    is always true.

    Will be true ONLY if you assign something that is not 0 to it (something that can be interpreted as being True or False) ... How are you doing this testing? Why would you care about the contents of the caption thru the label properties? Accessing the caption thru the properties is a DESIGN VIEW ONLY option ...

  3. #3
    Join Date
    Jan 2004
    Location
    South Africa
    Posts
    178

    Re: changing caption of a label

    Originally posted by M Owen
    WHAT???

    IF me.Label.Caption
    is always true.

    Will be true ONLY if you assign something that is not 0 to it (something that can be interpreted as being True or False) ... How are you doing this testing? Why would you care about the contents of the caption thru the label properties? Accessing the caption thru the properties is a DESIGN VIEW ONLY option ...
    sorry
    accident
    i meant
    if me.Label.Caption = "Input" then
    blah blah

  4. #4
    Join Date
    Jan 2004
    Location
    South Africa
    Posts
    178

    Re: changing caption of a label

    Originally posted by actionant
    sorry
    accident
    i meant
    if me.Label.Caption = "Input" then
    blah blah
    i've tried to do it using textboxes and checking the Values, but that just doesn't work at all.

    What happens is, a person logs in and there name is assigned to a label.
    then certain things must be done according to who logged in.

  5. #5
    Join Date
    Mar 2002
    Location
    Bielefeld, Germany
    Posts
    69
    Hi! Could you give us a little more details about what you're trying to achieve?

    And:

    You set caption in the properties window = "Blubb"

    msgbox me!label.caption 'returns "Blubb"
    me!label.caption="Blah" 'changes caption on screen
    msgbox me!label.caption 'returns "Blah"
    If me!label.caption = "Blah!" then 'returns "Hurray!"
    msgbox "Hurray!"
    else
    msgbox "Oops!"
    end if

    If you close the form, the caption will be "Blubb" again.

  6. #6
    Join Date
    Jan 2004
    Location
    South Africa
    Posts
    178
    not to worry
    I got it to work.
    i've ended up using textboxes, but the boxes are now situated on a different page. don't know why this was necessary but anyway.

    thanks for the help

  7. #7
    Join Date
    Dec 2003
    Location
    Dallas, TX
    Posts
    1,004

    Changing caption of a label

    actionant,

    Do this:This is saying your form has a StudentID field and FirstName and LastName fields that match the StudentID, here goes:

    FormDesignView, open the Toolbox, Select the Label tool and draw the box on your form and within that LabelBox type something like
    ' Student:Name' That's your placeholder. Now click out of that label then click it again, go to the Properties for that label and on the AllTab you'll see something like Label26. Either remember that name or rename it to something sensible. If you don't want a Heading:in the Caption area Delete it.
    NOW, Click on the form in the TopLeft corner and open it's Properties.
    Click on the EventTab, then the OnCurrent event and input this:

    Label26.Caption = "Student: " & [LastName] & ", " & [FirstName]

    That should do the trick.
    See if that works for you.
    Bud

Posting Permissions

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