Results 1 to 5 of 5
  1. #1
    MrOhhmy is offline Novice
    Windows 10 Access 2016
    Join Date
    Oct 2018
    Posts
    23

    Hide controls based on value list.

    Hello Experts. I seem to be having trouble with a simple code, whether on open, after update or what not. I simply want to hide some labels and text boxes for "Days" and display them for "Nights". I have attached the file and hope for some help on this. I have grouped the controls to be hidden by tag name Nights. So if Shift value box is Days, hide tag.Nights and if Nights, Visible = true. I've searched the forums and none of the codes work for me.



    Thanks,DW.zip

  2. #2
    davegri's Avatar
    davegri is online now Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,407
    Consider the above solution. It ignores the tags.
    It defines a rectangle to cover the night boxes and inserts a picture in the rectangle that matches the detail background.
    Then the shift combobox afterUpdate event makes the image visible to cover, or not visible to uncover the boxes.
    Last edited by davegri; 10-15-2018 at 09:44 PM. Reason: clarif

  3. #3
    MrOhhmy is offline Novice
    Windows 10 Access 2016
    Join Date
    Oct 2018
    Posts
    23
    Quick and dirty. This will work. Thank you.

  4. #4
    davegri's Avatar
    davegri is online now Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,407
    Glad to help. Keep it simple.

  5. #5
    MrOhhmy is offline Novice
    Windows 10 Access 2016
    Join Date
    Oct 2018
    Posts
    23
    So it turns out I had extra characters in the original form that was giving me the headache. My simple code did what I wanted originally. So, for anyone wanting to hide a set of controls, tag them with the same name. In my case, I tagged them "Nights". The following code works well for "On Load" with the controls in question set to Visible= No.

    Private Sub Form_Load()
    Dim ctrl As Control

    For Each ctrl In Me.Controls
    If ctrl.Tag = "Nights" And Shift = "Nights" Then
    ctrl.Visible = True
    End If
    Next
    End Sub

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

Similar Threads

  1. Replies: 2
    Last Post: 10-03-2018, 10:52 PM
  2. Replies: 2
    Last Post: 03-07-2018, 11:00 PM
  3. How to hide controls (Tab control)
    By Bill Neilsen in forum Forms
    Replies: 3
    Last Post: 08-07-2014, 02:27 AM
  4. Combobox-dependent show/hide controls
    By focosi in forum Forms
    Replies: 3
    Last Post: 07-31-2011, 06:47 AM
  5. Hide The Object List in 07
    By cassidym in forum Database Design
    Replies: 2
    Last Post: 07-13-2010, 02:18 PM

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
  •  
Other Forums: Microsoft Office Forums