Results 1 to 6 of 6
  1. #1
    MSS438 is offline Novice
    Windows XP Access 2003
    Join Date
    Jul 2012
    Location
    Indiana
    Posts
    3

    Make fields visible with selection in Option Group

    Hello All,



    I have a form with a sub-form. It has a one to many relationship based on a case #. In the sub-form I have an Option Group with 7 options that distinguish the item type. Depending the the item type I need other information that is gathered in other fields in the sub-form. Based on the selection in the Option Group, I want some fields visible and others not. Some fields need to be visible all the time, others only visible part of the time.

    Basically, if option 1 is selected, I want fields A, B, C, D, H, I, L, O, and Z visible. If option 2 is selected, I want fields A, B, C, E, F, P, and Y visible. If option 3 is selected...

    I currently have no code written for this issue. I have all fields visible all the time and merely fill in the fields needed for the selected option. This method is no problem for me, but my co-workers have seen me working on this project and would also like to use the data base, so I have to make it a little more use friendly so the appropriate data is entered.

    Thanks in advance...

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    The basic method:

    http://www.baldyweb.com/ConditionalVisibility.htm

    In your case, I'd use Select/Case instead of If/Then. In fact, I'd use a loop of the controls and the tag property to store the options a textbox should be visible for.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Ok, I was curious enough to test:

    Code:
    Private Sub Frame5_AfterUpdate()
      Dim ctl                     As Control
    
      For Each ctl In Me.Controls
        'only check controls with something in the tag property
        If Len(ctl.Tag & vbNullString) > 0 Then
          'set the visibility of the control based on whether the
          'selection in the frame is present in the tag
          ctl.Visible = InStr(1, ctl.Tag, Me.Frame5)
        End If
      Next ctl
    End Sub
    With the tag property containing things like

    1
    1,2

    based on which option(s) the control should be visible for.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  4. #4
    MSS438 is offline Novice
    Windows XP Access 2003
    Join Date
    Jul 2012
    Location
    Indiana
    Posts
    3
    Thanks for the quick response. Unfortunately when terms such as "tag," "tag property" and "Select/Case" I'm lost. I am, for lack of a better term, a simple user of Access and know very little VB or code stuff. Even when it comes to where the specific code you are providing me is suppose to be put, I at a loss. Maybe this is more than what I should try to tackle, unless it can be simplified or dumbed down to novice level. Is that possible?

    Thanks again for your quick response and what you have already done.



    Quote Originally Posted by pbaldy View Post
    Ok, I was curious enough to test:

    Code:
    Private Sub Frame5_AfterUpdate()
      Dim ctl                     As Control
    
      For Each ctl In Me.Controls
        'only check controls with something in the tag property
        If Len(ctl.Tag & vbNullString) > 0 Then
          'set the visibility of the control based on whether the
          'selection in the frame is present in the tag
          ctl.Visible = InStr(1, ctl.Tag, Me.Frame5)
        End If
      Next ctl
    End Sub
    With the tag property containing things like

    1
    1,2

    based on which option(s) the control should be visible for.

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Sorry, lost track of this thread and I was volunteering at a big event last week. Did you get this sorted out?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #6
    MSS438 is offline Novice
    Windows XP Access 2003
    Join Date
    Jul 2012
    Location
    Indiana
    Posts
    3

    no, not resolved yet.

    Quote Originally Posted by pbaldy View Post
    Sorry, lost track of this thread and I was volunteering at a big event last week. Did you get this sorted out?
    Sorry for the delay in responding, I took a long weekend and made the most of it by not doing any work.

    No, I did not get this problem resolved. I would like some help, but if it is too complicated for a novice like me, I will stick with what I have.

    Thanks again for all the help.
    Mike

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

Similar Threads

  1. make fields visible onclick() button
    By rivereridanus in forum Programming
    Replies: 4
    Last Post: 06-25-2012, 11:08 PM
  2. Replies: 6
    Last Post: 09-27-2011, 04:39 PM
  3. Replies: 5
    Last Post: 05-17-2011, 11:02 AM
  4. Replies: 2
    Last Post: 01-06-2011, 04:38 AM
  5. Replies: 10
    Last Post: 12-31-2010, 12:35 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