Results 1 to 6 of 6
  1. #1
    rkr is offline Novice
    Windows 10 Access 2016
    Join Date
    Dec 2017
    Posts
    6

    Dynamic Conditional Formatting on Continues SbuForm

    I have a sub-form with a Textbox, combobox, and a hidden Textbox. I am trying to figure out how to hide the combobox if the value in the hidden textbox is 0.



    So far, I have tried condotional formatting, however, that only allows you to change the color and Enable property.

    I tried finding a way to loop through the controls using code such as below. But the issue is here, is I need the instance of the control, and that I can't find.

    Code:
    '    Dim iType As Integer
    '
    '    For Each ctl In Me!frm_Part_Management_Subform.Controls
    '        If ctl.Name = "txt_subform_Attribute_Type" Then
    '            iType = ctl.value
    '        End If
    '
    '        If ctl.Name = "cmb_Part_Attribute_Value_ListItems" Then
    '            If iType = 0 Then
    '                ctl.Visible = False
    '            Else
    '                ctl.Visible = True
    '            End If
    '        End If
    '    Next ctl

  2. #2
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    You can refer to the control directly, there is no need to loop thru all the controls - Me!controlname
    If Me!hiddentextbox=0 Then
    ...hide the combobox
    End If
    Note that if this is a continuous form this won't work as expected as changes will be made to every row.

  3. #3
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,016
    As aytee111 suggested, doing this, thru code, will format the Control on all Records, not just the current one! For this kind of thing, you must use Conditional Formatting.

    Don't have time to test this, but to hide the Combobox, I think you need to use Conditional Formatting to set the Back Color and the Fore Color to the same color as the underlying Form section...making it, in essence, 'invisible.'

    Clunky, but I think it's the only option available to you.

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  4. #4
    rkr is offline Novice
    Windows 10 Access 2016
    Join Date
    Dec 2017
    Posts
    6
    Yes, it will change all of them and that is exactly what I do not want.

    There has to be a way to reference that single instance, without using conditional formatting. Setting them both to the same color, doesn't really make it invisible. You can still see parts of it.

    Anyways, I will mark this as not possible.

  5. #5
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    You could set it to enabled=No, which will grey the box out. Maybe better than leaving it exposed.

  6. #6
    rkr is offline Novice
    Windows 10 Access 2016
    Join Date
    Dec 2017
    Posts
    6
    That is what I have done. so that the tab key skips it.

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

Similar Threads

  1. Replies: 2
    Last Post: 11-12-2015, 10:46 AM
  2. Need Help With Conditional Formatting
    By Ursa2312 in forum Access
    Replies: 3
    Last Post: 07-28-2015, 11:18 AM
  3. Replies: 6
    Last Post: 05-26-2013, 09:10 PM
  4. Conditional Formatting
    By riaarora in forum Access
    Replies: 2
    Last Post: 08-12-2012, 02:09 AM
  5. Conditional Formatting
    By pkstormy in forum Code Repository
    Replies: 0
    Last Post: 08-30-2010, 09:31 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