Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Visible form based on Combo box selection? 2

Status
Not open for further replies.

ScorpioX

MIS
Apr 30, 2003
63
US
Hi All,
I have a problem which has been haunting me for a long time now. I am trying to get a subform to open (become visible) when a certain value is chosen in a combo box. Anyone have any ideas on how I can do this? I have included some info below.
Combo1 is for: Truck/Car
Combo2 is for: Fullsize/Midsize/2door/4door/Etc.
Combo1 and Combo2 are synced together. What I want is when the user chooses, say 2Door it will make the 2Door subform become visible. If they choose 4Door it make the the 4Door subform visible.
Any help is appreciated,
Thanks,
ScorpioX
 
eh, I'm assuming that you have 1 subform for each of these options, and they are all invisible...

if that's true then what you'd need to do is to put some code in the onClick event of your combobox...

onClick()
if cbx = "2Door" then
subFrm.visible = true
endif
end

remember to set them back to invisible after you're done with them
 
Hi

Depends to a degree on how you have defined your MainForm/subforms

If you have a mainform and 'n' subform controls containing subforms then

Select Case combo2
case "2 Door"
SubFormControl2Door.Visible = True
SubFormControl4Door.Visible = false
...etc for remaining subforn controls
Case "4 Door"

SubFormControl4Door.Visible = True
SubFormControl2Door.Visible = false
...etc for remaining subforn controls

If you have (as I would have done), a single subformcontrol, and set the .sourceobject to the name of the appropriate subform as required then:

Select Case combos2
case "2 Door"
me.subformcontrol.sourceobject = "frm2Door"
case "4 Door"
me.subformcontrol.sourceobject = "frm4Door"

...etc


You need to use your own control names of course, and if I were doing it I would incorporate the form name in the table which provides the drop down in combo2, then it would save hard coding the form names, making the application more flexible

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Thank you to both Crowley 16 and KenReay,
Crowley16 yours pointed me to the right event. KenReay your code worked like a charm. I have given you both a Star.

Thanks again,
ScorpioX [flip]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top