FormatCondition

  • Thread starter Thread starter swas
  • Start date Start date
S

swas

Hi,

Is it possible to have a conditional format to set, for example, the
..Visible property of a control? Or is it only possible to use the
FormatCondition members such as .ForeColor etc...?

Thanks in advance.


swas
 
You cannot use Conditional Formatting to change the visibility of a control.
You can fudge it by changing the color (e.g. white on white.)

A better solution might be to show null for the condition you want to hide
the text. For example, instead of a ControlSource of:
NumberOfPregnancies
use:
=IIf([Gender]="M", Null, [NumberOfPregnancies])

If that's not suitable either, use the Format event procedure of the section
containing the control to set its Visible property.
 
Allen,

Thanks for the reply.

I can't 'fudge it' as you suggest, because it is to make a checkbox behind
my combo visible which wouldn't be achieved by white foreground / background.

The OnFormat seems like a good solution, but my reading suggests this is
only for reports? A report has this event to use, but I can't find any
reference to it in a forms properties (Neither the properties window, or the
VB code). However, the Microsoft Online help says it applies to both Forms
and Report objects.

The control I want to set / clear the .visible property is in the form
detail section, and I am using continuous forms view, Access 2003. Depending
on some other controls values, I want to allow the user to have a multiple
choice (ie. combobox), or yes / no checkbox displayed - both will be updating
the same field via code. I don't know if this info helps.


Thanks again.


swas

Allen Browne said:
You cannot use Conditional Formatting to change the visibility of a control.
You can fudge it by changing the color (e.g. white on white.)

A better solution might be to show null for the condition you want to hide
the text. For example, instead of a ControlSource of:
NumberOfPregnancies
use:
=IIf([Gender]="M", Null, [NumberOfPregnancies])

If that's not suitable either, use the Format event procedure of the section
containing the control to set its Visible property.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

swas said:
Hi,

Is it possible to have a conditional format to set, for example, the
.Visible property of a control? Or is it only possible to use the
FormatCondition members such as .ForeColor etc...?

Thanks in advance.


swas
 
You're right: the Format event applies to forms only.

You cannot selectively hide a control in a continuous form.

There may be a quirky workaround by placing a text box on top of your check
box (Format | Bring To Front), and setting it to show a WingDings character
that simulates a check box for the conditions where you want the
checked/unchecked box to appear, but to show null for the conditions where
the check box should "hide." For editing, you can SetFocus to the real check
box when you want it (it jumps forward on the current row only), or SetFocus
to the previous/next control if it is "hiding" on the current row.
 
Allen,

Thanks again. I still have the problem of making the combobox disappear (Or
make the textbox overlap the Combobox...).

All getting a bit messy, so I think I will just review using a combobox
only, and managing when only a yes / no input is required. I think sometimes
it is more of an issue of good form design in the first place.

Appreciated.


swas
 
Just to finish this off, I found using the combobox.mousedown event was
handy - if the other fields meet the need for a checkbox, and button=left
with no shift/alt/ctrl then I automatically set / clear the combo. It ends up
being a reasonable checkbox emulation...

Regards


swas
 
Back
Top