Results 1 to 6 of 6
  1. #1
    Join Date
    Aug 2003
    Posts
    9

    Unanswered: Changing labels based on textbox value

    In a form, is it possible to change a label for one record based on the text box value next to it, or does this have to be done on the reporting end of it?

    I figured out how to change the label programatically, but it changes for all records.

    Here's my code on the form just to give you an idea of what I'm doing:

    Private Sub txtrec1_Exit(Cancel As Integer)

    Select Case txtrec1.Value
    Case "1", "21", "31"
    lblrec1.Caption = "st"
    Case "2", "22"
    lblrec1.Caption = "nd"
    Case "3", "23"
    lblrec1.Caption = "rd"
    Case "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "24", "25", "26", "27", "28", "29", "30"
    lblrec1.Caption = "th"
    Case Else
    lblrec1.Caption = ""
    End Select

    End Sub

  2. #2
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    delete the textbox label, add an unbound textbox, delete the new textbox label, format the new textbox so it looks like a label (transparent border & background) and use as its data

    iif(right$(textrec1, 1) = "1", "st", iif(right$(textrec1, 1) = "2", "nd", iif(right$(textrec1, 1) = "3", "rd", "th")))

    izy

  3. #3
    Join Date
    Sep 2002
    Location
    Finland
    Posts
    34

    Re: Changing labels based on textbox value

    Hi,

    Labels have same value/text for all records.

    You could use TextBox instead of Label.
    Use example Choose-function for ControlSouce:

    =Choose(Right([txtrec1];1);"st";"nd";"rd";"th";"th";"th";"th";"th";"th")

  4. #4
    Join Date
    Aug 2003
    Posts
    9

    Re: Changing labels based on textbox value

    Thank you everybody!

  5. #5
    Join Date
    Aug 2003
    Posts
    9

    Re: Changing labels based on textbox value

    One more question on the choose function. How do I account for blanks? I want the text to be blank when there is no value in txtrec1.

  6. #6
    Join Date
    Aug 2003
    Posts
    9
    nevermind, got it!

Posting Permissions

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