How to blank a control on a report (1 Viewer)

Gkirkup

Registered User.
Local time
Yesterday, 16:47
Joined
Mar 6, 2007
Messages
628
I have a report which prints a label, but based on a certain criteria, sometimes one of the fields should not be printed.
How do I do that? I have tried adding me.myfield = "" in Report Open etc, but then it either does nothing or the report does not print at all.
How do I selectively blank or not print a field on the report?

Robert
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 16:47
Joined
Oct 29, 2018
Messages
21,473
Lots of ways to do it. However, let me ask this first. Are you trying to reclaim the space it occupies? In other words, did you not want to see a gap or an empty space where the field would have been?
 

Gkirkup

Registered User.
Local time
Yesterday, 16:47
Joined
Mar 6, 2007
Messages
628
DBguy: I would be happy to make the field invisible. However if I could replace it with something else then so much the better.

Robert
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 16:47
Joined
Oct 29, 2018
Messages
21,473
DBguy: I would be happy to make the field invisible. However if I could replace it with something else then so much the better.

Robert
Hi Robert. That wasn't my question. Invisible controls still exist; although they can't be seen. Which means, they still occupy a space. For example, if you had a layout like this:
Code:
Field1   Field2   Field3
XXX      XXX      XXX
We can make Field2 invisible, and it might look like this:
Code:
Field1            Field3
XXX               XXX
My question was, is the above result acceptable, or were you expecting to get something more like this?
Code:
Field1   Field3
XXX      XXX
 

MajP

You've got your good things, and you've got mine.
Local time
Yesterday, 19:47
Joined
May 21, 2018
Messages
8,528
I did some demos here and went into discussions of what can be "blanked" in report view and what can really be hidden in print preview. Are you hiding just a control or a whole record?
In print preview you cannot set it invisible. You can make it appear to be invisible by setting the forecolor = the backcolor.
The events you need are OnFormat and OnPrint
 

Gkirkup

Registered User.
Local time
Yesterday, 16:47
Joined
Mar 6, 2007
Messages
628
dbGuy: Thanks for making that clear. The report is actually a label with the fields stacked in boxes. So having one empty box on the label would be no problem at all.

Robert
 

MajP

You've got your good things, and you've got mine.
Local time
Yesterday, 19:47
Joined
May 21, 2018
Messages
8,528
I think I misunderstood. You want to hide this for the whole report and not based on specific records (which is harder).
 

bastanu

AWF VIP
Local time
Yesterday, 16:47
Joined
Apr 13, 2010
Messages
1,402
Have you tried to do it in the report's record source?

HideShowField:IIF(CertainCriteria=True,"NO DATA",[Field])

Then you don't need to modify the report at all.

Cheers,
Vlad
 

Gkirkup

Registered User.
Local time
Yesterday, 16:47
Joined
Mar 6, 2007
Messages
628
There is only one record in the report. It prints a label. But based on criteria, one field may not be printed. No problem leaving a blank space on the label.

Robert
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 16:47
Joined
Oct 29, 2018
Messages
21,473
There is only one record in the report. It prints a label. But based on criteria, one field may not be printed. No problem leaving a blank space on the label.

Robert
The simplest approach might be to change/convert the Label into a Textbox (or replace it with a Textbox without a Label).

Then, in the Control Source, you could try something like:

Code:
=IIf([FieldName] & "" = "", "", "Actual Label You Want To Use")

To make the new Textbox look like a Label. Set the following properties:

Enabled = No
Locked = Yes
Border = Transparent

Hope it helps...
 

bastanu

AWF VIP
Local time
Yesterday, 16:47
Joined
Apr 13, 2010
Messages
1,402
Hi DbGuy, I think Robert means a "shipping" or "file" label not an actual label control. But the approach would be the same, in the control source of the field printed conditionally add the expression you have or do it in the report's source as I suggested.
Hope it helps!

Cheers,
Vlad
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 16:47
Joined
Oct 29, 2018
Messages
21,473
Hi DbGuy, I think Robert means a "shipping" or "file" label not an actual label control. But the approach would be the same, in the control source of the field printed conditionally add the expression you have or do it in the report's source as I suggested.
Hope it helps!

Cheers,
Vlad
Oops, I've been reading this whole thread wrong then. Sorry...
 

Users who are viewing this thread

Top Bottom