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.
Dynamically Unhiding Fields base on selected data
Collapse
X
-
Hi,Originally posted by KingKenI 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.
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 -
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
-
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.Originally posted by KingKenThanks 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.
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.
JimComment
-
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
-
You go, KennyKingyBoyPa lBuddyMateyPalS onKidAce,Originally posted by KingKenI'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.
Glad you worked it out, fun isn't it?
Oh and just Jim will do.
JimComment
Comment