Results 1 to 7 of 7

Thread: Checkbox and a textbox help pls.

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Dec 2002
    Location
    philippines
    Posts
    81

    Talking Checkbox and a textbox help pls.

    i got 2 checkboxes one is [] YES and one is []NO and a textbox.
    It is like an interview question where if u say yes you gonna write something on the textbox and if its NO then you wouldnt write anything to it... now the problem..

    In default the textbox is disabled. if i click the Checkbox YES the textbox will enable itself, and if i click it again it will disable itself.

    The problem is when i click YES for the first time NOTHING HAPPENS the textbox is still disabled, when i click it again (checkbox YES is checked).. it disables... what seems to be the problem with it?

    heres my code...


    Private Sub chkdryes_Click()
    If chkdryes = yes Then
    txtdrugs.Enabled = True
    txtdrugs.BackColor = vbWhite
    Else
    txtdrugs.Enabled = True
    txtdrugs.BackColor = vbGray
    End If
    End Sub


    Any ideas?
    DSN

  2. #2

  3. #3
    Junior Member
    Join Date
    Jun 2003
    Location
    Dallas, TX
    Posts
    21
    Just to provide a visual:

    VB Code:
    1. Private Sub chkdryes_Click()
    2. If chkdryes.Value = Checked Then
    3. ' This was the problem
    4. txtdrugs.Enabled = True
    5. txtdrugs.BackColor = vbWhite
    6. Else
    7. txtdrugs.Enabled = True
    8. txtdrugs.BackColor = vbGray
    9. End If
    10. End Sub

  4. #4
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431
    Originally posted by shmuclez
    Just to provide a visual:

    VB Code:
    1. Private Sub chkdryes_Click()
    2. If chkdryes.Value = [color="#FF0080"]Checked[/color] Then
    3. ' This was the problem
    4. txtdrugs.Enabled = True
    5. txtdrugs.BackColor = vbWhite
    6. Else
    7. txtdrugs.Enabled = True
    8. txtdrugs.BackColor = vbGray
    9. End If
    10. End Sub
    Should be vbChecked.

  5. #5
    Junior Member
    Join Date
    Jun 2003
    Location
    Dallas, TX
    Posts
    21
    worked fine for me my way, i just used Checked

  6. #6

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Dec 2002
    Location
    philippines
    Posts
    81

    Talking SOLVED!!!!

    Thanks for the fast reply

    I thought it was YES/NO

    thanks guys!!!
    DSN

Posting Permissions

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



Click Here to Expand Forum to Full Width