conditional formating

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hopefully this is a simple question.

I want to include a field if the comments are not "Comment here".

Here's what I have for a control called FilteredComment...
=IIf([Comment]="Comment here",(FilteredComment.Visible=No),[Comment]) The
problem is the true part doesn't work the way I want it to work. I want to
make the comment disappear if it's "Comment here". So I need to set either
the height to 0 or visible prpoerty to No. How do I do it?

The value of this control is also set to CanGrow and CanShrink - Yes.
[Comment] itself is a hidden field. I'm also getting the circular reference
erro but that doesn't seem to be problematic.
 
Michael said:
I want to include a field if the comments are not "Comment here".

Here's what I have for a control called FilteredComment...
=IIf([Comment]="Comment here",(FilteredComment.Visible=No),[Comment]) The
problem is the true part doesn't work the way I want it to work. I want to
make the comment disappear if it's "Comment here". So I need to set either
the height to 0 or visible prpoerty to No. How do I do it?

The value of this control is also set to CanGrow and CanShrink - Yes.
[Comment] itself is a hidden field. I'm also getting the circular reference
erro but that doesn't seem to be problematic.


You can not use a statement in the middle of an expression.
Note that a value of Null or "" or being invisible is
sufficient to get a text box to shrink.

Either perform the logic in an event procedure:

Me.Comment.Visible = (Me.[Comment] <> "Comment here")

in which case, you do not need the FilteredComment text box
at all.

Or, use an expression that results in a shrinkable value:

=IIf([Comment]="Comment here", Null, [Comment])

Which can be used in the comment text box without using the
FilteredComment text box. Just make sure you change the
name of the text box to something other than Comment,
txtComment would be a good name.
 
Ironically enough I did have "" in as the true part to start. I had copied
it from another control and never thought to try it. I ended up using an if
then statement in the OnFormat...
If Me.Comment = "Comment here" Then
[FilteredComment].Height = 0
Else
End If

It works just the same, do you suppose it matters? Is one better than the
other?

Marshall Barton said:
Michael said:
I want to include a field if the comments are not "Comment here".

Here's what I have for a control called FilteredComment...
=IIf([Comment]="Comment here",(FilteredComment.Visible=No),[Comment]) The
problem is the true part doesn't work the way I want it to work. I want to
make the comment disappear if it's "Comment here". So I need to set either
the height to 0 or visible prpoerty to No. How do I do it?

The value of this control is also set to CanGrow and CanShrink - Yes.
[Comment] itself is a hidden field. I'm also getting the circular reference
erro but that doesn't seem to be problematic.


You can not use a statement in the middle of an expression.
Note that a value of Null or "" or being invisible is
sufficient to get a text box to shrink.

Either perform the logic in an event procedure:

Me.Comment.Visible = (Me.[Comment] <> "Comment here")

in which case, you do not need the FilteredComment text box
at all.

Or, use an expression that results in a shrinkable value:

=IIf([Comment]="Comment here", Null, [Comment])

Which can be used in the comment text box without using the
FilteredComment text box. Just make sure you change the
name of the text box to something other than Comment,
txtComment would be a good name.
 
Michael said:
Ironically enough I did have "" in as the true part to start. I had copied
it from another control and never thought to try it. I ended up using an if
then statement in the OnFormat...
If Me.Comment = "Comment here" Then
[FilteredComment].Height = 0
Else
End If

It works just the same, do you suppose it matters? Is one better than the
other?

Well, the text box won't show if its Height is zero, but
that's not the same as shrinking. If the text box's
CanShrink and its section's CanShrink are both set to Yes
and there's nothing else in the same horizontal "band" as
the text box, then the controls below will move up. They
won't do that if you set the Height to 0.
--
Marsh
MVP [MS Access]



Michael said:
I want to include a field if the comments are not "Comment here".

Here's what I have for a control called FilteredComment...
=IIf([Comment]="Comment here",(FilteredComment.Visible=No),[Comment]) The
problem is the true part doesn't work the way I want it to work. I want to
make the comment disappear if it's "Comment here". So I need to set either
the height to 0 or visible prpoerty to No. How do I do it?

The value of this control is also set to CanGrow and CanShrink - Yes.
[Comment] itself is a hidden field. I'm also getting the circular reference
erro but that doesn't seem to be problematic.
Marshall Barton said:
You can not use a statement in the middle of an expression.
Note that a value of Null or "" or being invisible is
sufficient to get a text box to shrink.

Either perform the logic in an event procedure:

Me.Comment.Visible = (Me.[Comment] <> "Comment here")

in which case, you do not need the FilteredComment text box
at all.

Or, use an expression that results in a shrinkable value:

=IIf([Comment]="Comment here", Null, [Comment])

Which can be used in the comment text box without using the
FilteredComment text box. Just make sure you change the
name of the text box to something other than Comment,
txtComment would be a good name.
 
Back
Top