Make only one of several subforms visible

vangogh228

Registered User.
Local time
Today, 18:16
Joined
Apr 19, 2002
Messages
302
Hello all.

I have orders being entered, some of which may be in any one of several categories for which we need additional information. I would like to be able to have either a set of checkboxes answering the question "Check the appropriate box if the order is one of the following types" ... or ... have a radio-button selection where only one can be chosen at a time. That is important... that only one be able to be chosen at a time. It is possible to have orders outside this set of choices, and no selection made at all. Once the selection is made, I'd like either the appropriate fields to show in the main form... or ... have the appropriate subform show based on the entry from the checkboxes or radio selection.


I could have

OrderEntryForm containing
checkboxes or radio selection for Type1, Type2, Type3 with the appropriate Type1fields, Type2fields, and Type3fields hidden until the right checkbox or radio button is selected.


or

OrderEntryForm containing
checkboxes or radio selection for Type1, Type2, Type3 with the appropriate subforms Type1form, Type2form, and Type3form hidden until the right checkbox or radio button is selected.



There's only one problem: I have no idea how to make this happen... nor which way of doing this is best. Any help is GREATLY appreciated.

Tom
 
Very possible!

Hi VanGough

What you propose is quite possible, but without knowing the layout of your forms and the number of fields that are in each of the scenario's, it is difficult to advise which is the best method to implement.

Either way, this can best be achieved using code - How are your VBA skills?

What you need to do is set up an Option Group (which you can choose tick boxes, radio buttons etc. to display) which will restrict the user to a single option. You can also set the option group to have a default value.

Once you have set this up, create the fields or subforms and set their default visible property to No - so when the main form loads, all are hidden.

Now that you have the forms laid out, we need to code what to do when the option group is selected. In the After Update event of the option group, get the value of group and by using either an IF or CASE statements, set the fields / subforms visible status to True. (Remember to include the Else clause - no/null selection - which should set all fields / subforms visible property to false.)

Post back if you want more help with the code.

Regards
Rod
 
Last edited:
Thinking this through - If you do not save the option group result to a table, the info will be captured, but you will not be able to access the data using the form unless the user knows what option to select to display it again. If you are happy to store this in the table, you should copy the code from the After Update procedure to the main form's On Current event.

Just a thought...
Rod
 
Thanks for the heads up on the option group. I tried this out based on what you said, and was able to get a subform to appear/disappear based on the choice in a checkbox. I'll try it with an option group next... and multiple subforms. I think I can get through it from here, as the VBA is pretty simple... which is perfect given my pathetic code skills.

THANKS!
 

Users who are viewing this thread

Back
Top Bottom