Dynamically Unhiding Fields base on selected data

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • KingKen
    New Member
    • Feb 2008
    • 68

    Dynamically Unhiding Fields base on selected data

    I am having a form with some hidden fields and want them to be displayed only when a certain value in another combo box is selected. for example, whenever system unit is selected in the box, the fields for processor speed, harddrive and internal adaptor cards will be selected. can someone please help.
  • JustJim
    Recognized Expert Contributor
    • May 2007
    • 407

    #2
    Originally posted by KingKen
    I am having a form with some hidden fields and want them to be displayed only when a certain value in another combo box is selected. for example, whenever system unit is selected in the box, the fields for processor speed, harddrive and internal adaptor cards will be selected. can someone please help.
    Hi,
    In the "After Update" event of your "system unit" (text?)box use a Select Case statement and set the .Visible property of the other (text?)boxes as appropriate.

    Jim

    Comment

    • KingKen
      New Member
      • Feb 2008
      • 68

      #3
      Thanks for your response. you guys are a professional blessing.

      "System Unit" is an option in a combo box. the rest is a mixture of combo boxes and text boxes that are hidden. what i need is whenever system unit is selected these items (Hidden text and combo boxes) will be unhidden. Further, if a record has system unit as its properity when it comes into focus then all the hidden fields are displayed to reveal the full data of the system. I am not so sure that the after update covers this aspect.

      Another idea i can accomodate is to use a check box that will unhide the hidden fields when checked. I rather the first though. it looks more efficient

      I am not good at programming so a little help with that would be greatefully appriciated Thanks.

      Comment

      • JustJim
        Recognized Expert Contributor
        • May 2007
        • 407

        #4
        Originally posted by KingKen
        Thanks for your response. you guys are a professional blessing.

        "System Unit" is an option in a combo box. the rest is a mixture of combo boxes and text boxes that are hidden. what i need is whenever system unit is selected these items (Hidden text and combo boxes) will be unhidden. Further, if a record has system unit as its properity when it comes into focus then all the hidden fields are displayed to reveal the full data of the system. I am not so sure that the after update covers this aspect.

        Another idea i can accomodate is to use a check box that will unhide the hidden fields when checked. I rather the first though. it looks more efficient

        I am not good at programming so a little help with that would be greatefully appriciated Thanks.
        OK, what you want is for two different events (The combo box's AfterUpdate & the form's OnCurrent) to do the same thing. What we will do is get the AfterUpdate event working then point the OnCurrent event to the same code.

        The combo box's after update event should have the following code.

        [CODE=vb]Sub cboYourComboNam e_AfterUpdate()
        If cboYourComboNam e.Text = "System Unit" then
        Me.txtYourTextB oxName.Visible = True
        Me.cboYourOther ComboBoxName.Vi sible = True
        Else
        Me.txtYourTextB oxName.Visible = False
        Me.cboYourOther ComboBoxName.Vi sible = False
        End if
        End Sub[/CODE]

        Change the names to the names you have used on your form and give that a go.

        If it works just fine, the the form's OnCurrent event just has to be
        [CODE=vb]Sub frmYourFormName _OnCurrent()
        Call cboYourComboNam e_AfterUpdate()
        End Sub[/CODE]

        Let us know how you get on.

        Jim

        Comment

        • KingKen
          New Member
          • Feb 2008
          • 68

          #5
          The after update event worked fine, however when trying to use the onCurrent event to call the afterUpdate event you get the debug message.
          It seems to be having problems reading this line

          If HardwareTypeID. Text = "System Unit" Then

          Comment

          • KingKen
            New Member
            • Feb 2008
            • 68

            #6
            I've got it jiimmy boy
            I added this piece of code

            Private Sub Form_Current()
            HardwareTypeID. SetFocus
            If Me.HardwareType ID.Text = "System Unit" Then

            and added the fields like you showed me for the afterUpdate event. there might be a better way to do it since i had to basically repeat the same thing twice. but for a novice at programming... this stuff adds geek propositionalit ies to my stature among my colleges.

            By the way, they dont't know that I am using this forum for all the "I don't think that's possible" answer. You guys are the reel geeks thanks.

            Comment

            • JustJim
              Recognized Expert Contributor
              • May 2007
              • 407

              #7
              Originally posted by KingKen
              I've got it jiimmy boy
              I added this piece of code

              Private Sub Form_Current()
              HardwareTypeID. SetFocus
              If Me.HardwareType ID.Text = "System Unit" Then

              and added the fields like you showed me for the afterUpdate event. there might be a better way to do it since i had to basically repeat the same thing twice. but for a novice at programming... this stuff adds geek propositionalit ies to my stature among my colleges.

              By the way, they dont't know that I am using this forum for all the "I don't think that's possible" answer. You guys are the reel geeks thanks.
              You go, KennyKingyBoyPa lBuddyMateyPalS onKidAce,
              Glad you worked it out, fun isn't it?
              Oh and just Jim will do.

              Jim

              Comment

              Working...