Results 1 to 6 of 6
  1. #1
    Join Date
    Apr 2012
    Posts
    31

    Question Unanswered: Combo box to grey/ungrey text box when 1 item from list is selected

    Hi guys/gals,

    I have a form with a combo box which has 4 items to choose from they are:

    father
    mother
    son
    daughter

    Next to the combo box is a text box.

    What I want to do is only when DAUGHTER is selected the text box can be typed into. Any other selection will result in the text box being 'grayed' out so you cant enter data in.

    Any help on this would be very much appreciated - including instruction on where to enter the code.

    this may have been answered in one form or another, but just cant get my head around it!!!

    Thanks a million in one two three.

    pj

  2. #2
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    Assuming that "father", "mother", "son", "daughter" are in the first (leftmost) column of the combo, you can use:
    Code:
    If Me.<ComboName>.Column(0) = "DAUGHTER" then
        Me.<TextBoxName>.Enabled = True
    Else
        Me.<TextBoxName>.Enabled = False
    End If
    You can use the code in the Combo_AfterUpdate event handler and, if the combo is bound, in the Form_Current event handler.
    Have a nice day!

  3. #3
    Join Date
    Apr 2012
    Posts
    31

    Finally...

    Yes this works. Thank you.

    to frost the cake so to speak:

    when i scroll back through the forms in the database, is there any way to keep the text box (on forms where DAUGHTER is used) 'un greyed' and where where FATHER, MOTHER or SON have been used keep those text boxes 'greyed out'?

    Warmest regards

    P.

  4. #4
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    Quote Originally Posted by MGF23 View Post
    Yes this works. Thank you.
    You're welcome!
    Quote Originally Posted by MGF23 View Post
    when i scroll back through the forms in the database, is there any way to keep the text box (on forms where DAUGHTER is used) 'un greyed' and where where FATHER, MOTHER or SON have been used keep those text boxes 'greyed out'?
    Simply copy the same code in the Form_Current event handler.
    Have a nice day!

  5. #5
    Join Date
    Apr 2012
    Posts
    31
    Once again thanks. Working perfectly! All the best.

  6. #6
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    You're welcome!
    Have a nice day!

Tags for this Thread

Posting Permissions

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