Page 1 of 2 12 LastLast
Results 1 to 15 of 17

Thread: Check Box

  1. #1
    Join Date
    Sep 2003
    Location
    Raleigh, NC
    Posts
    183

    Red face Unanswered: Check Box

    I'm creating database to keep track of patient who are enrolled in some kind of clinical study.

    I have form for the Patient "subfrmPatient" I have field name "chxEnroll" "EnrollDate", "EnrolleStatus" and "Not Enrolled Reason" Now my question is that each time user clicks on check box Enrolled i want "Enrolled Status" to be active and if they don't click the chxbox then i want user to enter "Not Enrolled Reason". I wrote if statement for chxBox but since its subform if statement doesn't really work good.

    Any suggestion ?
    Skharva

  2. #2
    Join Date
    Sep 2001
    Location
    Chicago, Illinois, USA
    Posts
    601
    If all this is on the same form, then the fact that it is a subform should have no bearing.

    Your question is not clear. You say:

    "I have field name "chxEnroll" "EnrollDate", "EnrolleStatus" and "Not Enrolled Reason""

    Is that a single field or four checkboxes?

    Is the "Not Enrolled Reason" another field that is a textbox?
    Ken

    Maverick Software Design

    (847) 864-3600 x2

  3. #3
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    private sub chxEnroll_AfterUpdate()

    EnrolleStatus.visible = chxEnroll
    NotEnrolledReason.visible = not chxEnroll 'get RID of those spaces!!!!!!!

    end sub
    currently using SS 2008R2

  4. #4
    Join Date
    Sep 2003
    Location
    Raleigh, NC
    Posts
    183
    Originally posted by PracticalProgram
    If all this is on the same form, then the fact that it is a subform should have no bearing.

    Your question is not clear. You say:

    "I have field name "chxEnroll" "EnrollDate", "EnrolleStatus" and "Not Enrolled Reason""

    Is that a single field or four checkboxes?

    Is the "Not Enrolled Reason" another field that is a textbox?
    Yes they are all in one subform. chxEnroll is Checkbox......EnrollDate is a text field......Enroll Status and Not Enrolled Reason are combo box
    Skharva

  5. #5
    Join Date
    Sep 2003
    Location
    Raleigh, NC
    Posts
    183

    Red face

    Originally posted by izyrider
    private sub chxEnroll_AfterUpdate()

    EnrolleStatus.visible = chxEnroll
    NotEnrolledReason.visible = not chxEnroll 'get RID of those spaces!!!!!!!

    end sub
    I'm using your code in Subform. So lets say for example in my subform Record#1 i click on chxEnroll which makes "NotEnrolledReason" = Visible
    But as soon as i go to Record#2 and unchecked the chxEnroll it makes "NotEnrolledReason" = False for all my records.

    Is it because of subform ?
    Skharva

  6. #6
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    probably:

    try in the _Current() event for the subform:

    chxEnroll_AfterUpdate





    izy
    currently using SS 2008R2

  7. #7
    Join Date
    Sep 2003
    Location
    Raleigh, NC
    Posts
    183
    Originally posted by izyrider
    probably:

    try in the _Current() event for the subform:

    chxEnroll_AfterUpdate


    It still doesn't wrk right. Would it help if i send you db ?


    izy
    Skharva

  8. #8
    Join Date
    Sep 2001
    Location
    Chicago, Illinois, USA
    Posts
    601
    "But as soon as i go to Record#2 and unchecked the chxEnroll it makes "NotEnrolledReason" = False for all my records."

    This is because your checkboxes (and whatever else) are not bound to data in the table/query which is the SourceObject of your subform.
    Ken

    Maverick Software Design

    (847) 864-3600 x2

  9. #9
    Join Date
    Sep 2003
    Location
    Raleigh, NC
    Posts
    183
    Originally posted by izyrider
    probably:

    try in the _Current() event for the subform:

    chxEnroll_AfterUpdate





    izy
    I have attached the database.
    Attached Files Attached Files
    Skharva

  10. #10
    Join Date
    Sep 2001
    Location
    Chicago, Illinois, USA
    Posts
    601
    You cannot change any of the "visible attributes" of a control on a subform without changing that attribute for all records.

    So, if you make a control invisible, it makes that control invisible for all records.

    The best you can do is make the control Locked and Disabled, which are both "invisible attributes" of controls.

    So, your OnCurrent event would have something like this:

    txtEnrolledDate.Enabled = chxEnrolled
    txtEnrolledDate.Locked = Not chxEnrolled
    Ken

    Maverick Software Design

    (847) 864-3600 x2

  11. #11
    Join Date
    Sep 2003
    Location
    Raleigh, NC
    Posts
    183
    Originally posted by PracticalProgram
    You cannot change any of the "visible attributes" of a control on a subform without changing that attribute for all records.

    So, if you make a control invisible, it makes that control invisible for all records.

    The best you can do is make the control Locked and Disabled, which are both "invisible attributes" of controls.

    So, your OnCurrent event would have something like this:

    txtEnrolledDate.Enabled = chxEnrolled
    txtEnrolledDate.Locked = Not chxEnrolled
    I did that and it still the same problem. Any other suggestion ?
    Skharva

  12. #12
    Join Date
    Sep 2001
    Location
    Chicago, Illinois, USA
    Posts
    601
    This code should be on the AfterUpdate of the checkbox and on the OnCurrent of the subform.

    The AfterUpdate is for when you change the check box, the OnCurrent is for when you select a pre-existing record.
    Ken

    Maverick Software Design

    (847) 864-3600 x2

  13. #13
    Join Date
    Sep 2003
    Location
    Raleigh, NC
    Posts
    183
    Originally posted by PracticalProgram
    This code should be on the AfterUpdate of the checkbox and on the OnCurrent of the subform.

    The AfterUpdate is for when you change the check box, the OnCurrent is for when you select a pre-existing record.

    What about Onclick even of check box ?
    Skharva

  14. #14
    Join Date
    Sep 2001
    Location
    Chicago, Illinois, USA
    Posts
    601
    No, do not use the OnClick of the checkbox if you can use the AfterUpdate.

    AfterUpdate means "After" the value of the checkbox is "Updated" with the new value. So, you know, at that point, that the value of the checbox is exactly what you want.
    Ken

    Maverick Software Design

    (847) 864-3600 x2

  15. #15
    Join Date
    Sep 2003
    Location
    Raleigh, NC
    Posts
    183
    Originally posted by PracticalProgram
    No, do not use the OnClick of the checkbox if you can use the AfterUpdate.

    AfterUpdate means "After" the value of the checkbox is "Updated" with the new value. So, you know, at that point, that the value of the checbox is exactly what you want.


    So i don't think there is anyway i can hide the "txtEnrolledDate" when chxEnroll is not checked. And make it visible when chxEnroll is clicked.

    But your idea still works for me

    Thanks a lot
    Skharva

Posting Permissions

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