Results 1 to 12 of 12
  1. #1
    jlgray0127 is offline Competent Performer
    Windows 2K Access 2000
    Join Date
    Oct 2011
    Location
    Central Illinois
    Posts
    193

    Forms and Check Boxes

    I have a form, that when I open it, I want to be able to see all the textboxes that are on the form. When I click a check box, I want to hide multiple textboxes, up to 5 or 6 per check box. The below code, will get one checkbox to hide one text box, ([A10]) . I need to know how to get one check box to hide multiple text boxes. ([A10], [A20], [A30], ect)
    Any help is greatly appreciated!

    Private Sub Check254_AfterUpdate()
    If [A10].Visible = True Then
    [A10].Visible = False
    Else
    [A10].Visible = True
    End If


    End Sub

  2. #2
    pdebaets is offline Competent Performer
    Windows Vista Access 2010 (version 14.0)
    Join Date
    Jul 2010
    Location
    Los Angeles
    Posts
    235
    Is this a bound form? If so, then it is likely that you will need to hide/show text boxes after a checkbox is updated, AND ALSO when you navigate to a new record.

    I recommend you create a subroutine named "SetControlProperties" in your form module to do the work of setting the text box visible property, then call that subroutine from your form OnCurrent event procedure, and from your check box(es) AfterUpdate event procedure(s).

    the code in your SetControlProperties routine can look like this:

    sub SetControlProperties()
    [A10].Visible = MyCheckBoxControl1
    [A20].Visible = MyCheckBoxControl1
    [A30].Visible = MyCheckBoxControl1

    [A40].Visible = MyCheckBoxControl2
    [A50].Visible = MyCheckBoxControl2
    [A60].Visible = MyCheckBoxControl2

    '* etc...
    end sub

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Just use an If Then for each in the AfterUpdate.

    Or try this for each:
    Me.[A10].Visible = Not Me.Check254

    Peter has good point about having a procedure to call, if record navigation is allowed on this form.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  4. #4
    jlgray0127 is offline Competent Performer
    Windows 2K Access 2000
    Join Date
    Oct 2011
    Location
    Central Illinois
    Posts
    193
    the Below code worked wonderfully for multiple boxes.
    However... I have an issue with the boxes not acting the same... some, when they are checked, hide the proper text fields, and others, when they are unchecked, they hide the text boxes. I used the same code for each checkbox, only changing the Text Box names relevent to the particular check box.
    I need it so when the form opens, all Text boxes are visible, and check boxes are checked. When I Uncheck the boxes, that is when I want the text boxes hidden.
    Private Sub Check254_AfterUpdate()
    If [A10].Visible = True Then
    [A10].Visible = False
    Else
    [A10].Visible = True
    End If
    End Sub

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Are these unbound checkboxes?

    Set checkbox Default property to Yes.

    A checkbox will affect only certain textboxes? Will any checkboxes affect the same textboxes? Can there be more than one checkbox checked at a time? Are these checkboxes in an OptionGroup?

    Can you provide project for analysis?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  6. #6
    jlgray0127 is offline Competent Performer
    Windows 2K Access 2000
    Join Date
    Oct 2011
    Location
    Central Illinois
    Posts
    193
    Picture a grid. 12 text boxes across, and 10 down. I have a check box at the top of each column and will have one at the head of each row. When I check the box, I want it to deactivate the row. Each box in the row is a text box, representing a header for a column in a table.
    Somehow, though, I need to retain the fact that the row or column is deactivated when the box is unchecked... I may be making this just too difficult! lol

  7. #7
    jlgray0127 is offline Competent Performer
    Windows 2K Access 2000
    Join Date
    Oct 2011
    Location
    Central Illinois
    Posts
    193
    Quote Originally Posted by jlgray0127 View Post
    Picture a grid. 12 text boxes across, and 10 down. I have a check box at the top of each column and will have one at the head of each row. When I check the box, I want it to deactivate the row. Each box in the row is a text box, representing a header for a column in a table.
    Somehow, though, I need to retain the fact that the row or column is deactivated when the box is unchecked... I may be making this just too difficult! lol
    The checkboxes, are unbound at this time.

  8. #8
    jlgray0127 is offline Competent Performer
    Windows 2K Access 2000
    Join Date
    Oct 2011
    Location
    Central Illinois
    Posts
    193
    I found the issue... However, I have not fixed the issue...
    When I close the form and reopen it, the text boxes stay hidden, but it reverses the role of the box. So, if when first opened, you checked the box to hide the appointed text boxes. Close the form and reopen. The text boxes stay hidden, but the check box, will now be checked to show the box, rather than hide it, as it did the first time the form was opened.

  9. #9
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Sounds like the textbox Visible property is being saved when form closes. Try:
    DoCmd.Close acForm, Me.Name, acSaveNo

    Can you provide project for analysis?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  10. #10
    jlgray0127 is offline Competent Performer
    Windows 2K Access 2000
    Join Date
    Oct 2011
    Location
    Central Illinois
    Posts
    193
    Where would I enter this code?
    I am not sure what you're asking with Project Analysis.
    Thank you for all your help!

    Quote Originally Posted by June7 View Post
    Sounds like the textbox Visible property is being saved when form closes. Try:
    DoCmd.Close acForm, Me.Name, acSaveNo

    Can you provide project for analysis?

  11. #11
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    By provide project for analysis I mean: Can you give us your database to look at? Copy, remove confidential data, run Compact & Repair, zip if still large, attach to post. Attachment Manager is below the Advanced post editor.

    What method are you using to close the form - the X button or a custom button click?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  12. #12
    jlgray0127 is offline Competent Performer
    Windows 2K Access 2000
    Join Date
    Oct 2011
    Location
    Central Illinois
    Posts
    193
    Thank you! I just got it! I just put Me.Name, acSaveNo in the close property of the form and it worked. I have an Exit button, but also have not removed the close button from the top of the form either... if I were to leave it, no matter what, when the form closes, it will not save the formatting change. right? lol

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Check Boxes
    By jordanturner in forum Access
    Replies: 1
    Last Post: 10-01-2010, 09:29 AM
  2. Yes/No check boxes
    By Desstro in forum Forms
    Replies: 2
    Last Post: 05-03-2010, 04:26 AM
  3. To check or Un-Check all Boxes in a form
    By devcon in forum Forms
    Replies: 7
    Last Post: 05-01-2010, 12:03 AM
  4. Un-Check all Boxes
    By cotri in forum Forms
    Replies: 4
    Last Post: 04-30-2010, 12:53 PM
  5. check boxes
    By chiefmsb in forum Forms
    Replies: 1
    Last Post: 11-14-2006, 02:22 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums