Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2005
    Posts
    5

    Unanswered: Quick question on visible/hide

    I have a subform that has an option group and a text field, e.g is this a followup appointment (yes/no), then if yes, then explain......So select yes or no from option group and explain using text field as needed.

    Well I want the text field to be invisible if the option group=no (i.e no explanation needed). It works perfectly after when I manually click it back and forth but when the form loads, the default option is "no" so the form should open with the text field invisible IF there wasn't a record previously.

    Basically I want to be able to check the value on the option group and then show/hide the text field based on that, especially when the form/subform opens.

    Any suggestions please?

  2. #2
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    looks like you have visible/not switching in the option group _XxxxxUpdate() event: this event does not occur during _Load().

    design-view the textbox to visible/not to suit the default setting of your option group (not visible & no if i read your post correctly).

    "IF there wasn't a record previously" complicates things - maybe you just mean "if the form wasn't there" in which case the above stuff fixes it. if you meant something else, i think you need to explain more about what you are trying to achieve.


    izy
    currently using SS 2008R2

  3. #3
    Join Date
    Nov 2003
    Location
    LONDON
    Posts
    238
    Use the following code as a guide:

    Private Sub MyOptionGroup_AfterUpdate()
    ' if the option group value is 1 when the user selects Yes
    Me("Name Of Text Box").Visible = (Me("MyOptionGroup").Value = 1)
    End Sub

    justin

  4. #4
    Join Date
    Jul 2004
    Location
    Inverurie
    Posts
    628
    Assuming Yes = 0 and No = 1 (You can substitue these to suit your values)

    Code:
    Private Sub MyOptionGroup_AfterUpdate()
    If ListBox.Value = 0 Then Textbox.Visible = True
    ElseIf ListBox.Value = 1 then TextBox.Visible = False
    End If
    End Sub
    You could use similar code on the form's on load event incase you want to carry any values into that form at a later date:

    [code]
    Private Sub Form_Load()
    If ListBox.Value = 0 Then Textbox.Visible = True
    ElseIf ListBox.Value = 1 then TextBox.Visible = False
    End If
    '**Place other elements after this**
    End Sub

Posting Permissions

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