Results 1 to 4 of 4
  1. #1
    2 Star Lounger
    Join Date
    Apr 2002
    Location
    Arkansas, USA
    Posts
    163
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhiding on specific combo box selection (A2k)

    When I open my main form for data entry, I want to have several fields remain hidden until the user makes a specific selection in one of the comboboxes on my form. When the selection is made, and before tabbing to the next field, I would like the hidden fields to become visible. Likewise, if the same combobox selection is changed to a selection other than the specific selection, I want the fields that were made visible to become invisible again.

    I think this is fairly simple, I am just self taught and have only been using access for around a month. I am not versed in the use of events to the point that I would like to be.

    Thank you in advance for the help.

    Marc Roeder

  2. #2
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Unhiding on specific combo box selection (A2k)

    Lets say that your combo box is named cmbSelection.
    In the after update of the combo box put the some code like this:
    <pre>Private Sub cmbSelection_AfterUpdate
    If Me!cmbSelection = "Something" Then
    Me!TextBox1.Visible = True
    Else
    Me!TextBox1.Visible = False
    End If
    End Sub</pre>

    To make the textboxes visible or not when you browse the records add this code in the On Current event of the form.
    <pre>Private Sub Form_Current()
    cmbSelection_AfterUpdate
    End Sub</pre>

    Francois

  3. #3
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: Unhiding on specific combo box selection (A2k)

    Here's a slight variation of the code Francois used:
    [pre]
    Private Sub cmbSelection_AfterUpdate
    Me.TextBox1.Visible = (Me.cmbSelection = "Something")
    Me.TextBox2.Visible = (Me.cmbSelection = "Something")
    ' etc.
    End Sub

    Access evaluates the equation within the parentheses as being either True or False, and sets the .Visible property accordingly.
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  4. #4
    2 Star Lounger
    Join Date
    Apr 2002
    Location
    Arkansas, USA
    Posts
    163
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Unhiding on specific combo box selection (A2k)

    Thank you for the help. I am still a little fuzzy on VBA, but this definitely helps.

    Thanks again to both of you.

Posting Permissions

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