Results 1 to 13 of 13
  1. #1
    Join Date
    Aug 2004
    Posts
    364

    Unanswered: Combo box YES/NO to grey out a textbox?

    I have a combo box with yes/no selection and a checkbox on the same form.

    If No is selected in the combo box I want a checkbox to become greyed.
    If Yes is selected in the combo box I want a checkbox to become tickable.

    Any simple ideas?

    Cheers

    Tom

  2. #2
    Join Date
    Jul 2004
    Posts
    125
    You won't be able to grey it out, only disable/lock it.

    ComboBox_GotFocus or On Enter
    Me!CheckBox = False ' Crear value of checkbox
    Me!CheckBox.Enabled = True

    ComboBox _AfterUpdate
    If me!ComboBox= "No" Then Me!CheckBox.Enabled = False

  3. #3
    Join Date
    Jul 2004
    Posts
    125
    Sorry, I misread your post. It's a textbox and yes, you can grey it out.

    ComboBox_GotFocus or On Enter
    Me!TextBox = "" ' Clear value of textbox
    Me!TextBox.Enabled = True

    ComboBox _AfterUpdate
    If Me!ComboBox="No" Then Me!TexBox.Enabled = False

  4. #4
    Join Date
    Aug 2004
    Posts
    364
    Thanks for the code, i will give it a go. It is a checkbox which i want to blank out, not a textbox.

    Cheers

    Tom

  5. #5
    Join Date
    Aug 2004
    Posts
    364
    Sorry im having trouble getting it to work

  6. #6
    Join Date
    Aug 2004
    Posts
    364
    The above code only seems to clear the checkbox, it doesnt lock it when i select 'no' from the combo box.

    Any more ideas?

  7. #7
    Join Date
    Jul 2004
    Posts
    125
    I apologize again, the only disabling property for the CheckBox is locked.

    ' Set the checkbox's default value to Locked = Yes, in form design view, under
    ' the properties, Data tab.
    ' The names here refer to = Yes_No is the ComboBox
    ' Check_Box = CheckBox
    ' I copied the code from my test and if you use it, you'll have to rename the
    ' controls to the names you've given.

    Private Sub Yes_No_AfterUpdate()
    If Me!Yes_No = "No" Then
    Me!Check_Box.Locked = True
    Else
    Me!Check_Box.Locked = False
    End If
    End Sub
    ' Clears the value of the checkbox
    Private Sub Yes_No_Enter()
    Me!Check_Box = False
    End Sub

    ' If you clear the form the Check_Box's Locked state must be reset to Yes.

  8. #8
    Join Date
    Aug 2004
    Posts
    364
    Sorry about this but its just not working. The checkbox does not lock when the combo box is set to 'no'.

  9. #9
    Join Date
    Jul 2004
    Posts
    125
    Check the event properties of the combo box. Under On Enter and After update, it should display [Event Procedure]. This means that it is linked to the code. In any case, click on these event procedures just to see that you end up in the correct procedure. When you click on the right of the event procedure and it creates a new Sub, this means that you have a control naming error in the procedure. In this case, you will have to correct it. Also, bear in mind that the words Yes_No and Check_Box are my references, used as an example and you have to use the control names you've given.

  10. #10
    Join Date
    Aug 2004
    Posts
    364
    Can you email me your example so I can try it on my computer? moss2076@hotmail.com

    Cheers

    Tom

  11. #11
    Join Date
    Jul 2004
    Posts
    125
    Here is the sample db in Access 2000
    Attached Files Attached Files

  12. #12
    Join Date
    Aug 2004
    Posts
    364
    Thanks for that, it works perfectly on my computer so I will have a play around and see what I can do within my database.

    Many thanks!!

    Tom

  13. #13
    Join Date
    Aug 2004
    Posts
    364
    Ive copied the form into my database (Access in Office XP) and it works fine, but when i copy the combo and checkbox into one of my forms, they stop working.

Posting Permissions

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