HIding controls in sub form

J

J. Shrimp, Jr.

Have a form with eight data-sheet sub-forms.
One sub-form contains all 12 fields (controls),
the other seven contain four common fields
plus one - but only one- of the remaing eight
fields.
I set this up so if a user selects one paticular
field (control) to review, they don't need to look at
all twelve fields in a data sheet view which is kind
of big on the screen and makes it difficult to focus
on the one variable selected. The sub data sheets
have only five controls - the four common ones and
the fifth one selected by the user.
However, this is kind of cheesey - why have
seven sub-forms just so each form can display
one different field.
I tried to eleimante all but one form - have
the eight other fields hidden, and if a user
selects a paticular field (control) all controls
but that one control are hidden using the
standard me.subform!form.control.visible = false
format.
Doesn't work.
ALL controls are displayed in the data sheet
sub form, regardless of the field selected.
Is there any way to hide datasheet sub-form controls?
 
N

Nikos Yannacopoulos

You can show/hide a control in a subform through its Visible property
when the subform is in single form or continuous forms view, but not in
datasheet view. Likewise, you cannot set a control's width in
datasheet view, which would be an alternative way to show/hide controls
(columns).

You can do it in a different way though: have the four common fields
plus a fifth, unbound one in the subform, and use an expression like:

Me.SubformName.Controls("ControlName").ControlSource = Me.Combo1

Where Combo1 is a combo on the main form which lists the filed names in
the subform's recordsource. Note: all 12 fields nust be included in the
subform's recordsource.


Moreover, you can use the combo's Before Update event to run the code,
and do what you want in a single move!

HTH,
Nikos
 
N

Nikos Yannacopoulos

Malcolm,

There is no ColumnWidth property, I take it you are referring to the
Width property; well, that doesn't work in datasheet view.

I found out though that there is a ColumnHidded (boolean) property which
I wasn't aware of, and which does the job nicely!

Nikos
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top