Hiding text when control isNull.

Sniper-BoOyA-

Registered User.
Local time
Today, 14:51
Joined
Jun 15, 2010
Messages
204
Good Afternoon,

I am working on a report, and i was wondering if its possible to hide labels when a vaue of a field isNull or Empty.

Ive tried an If statement, and a Select Case statement.

But both methods result in not being able to open the report (it closes straight away).

The names of the labels i'd like to hide are:

Bijschrift247
Bijschrift249
Bijschrift252

Any thoughts?
 
Last edited:
What code have you used and where did you use it?
 
I used both

If Me.verhoudingzand Is Empty Then Me.Bijschrift247.Visible = False

and

Select Case [me.verhoudingzand]
Case isNull
me.bijschrift247.Visible = false
End Select

In the open event of the report.
 
try

Code:
If IsNull(Me.verhoudingzand) Then
  
    your code here


End If
 
thanks, but doesnt seem to have any effect.:(
 
Last edited:
I got it :D

In the Detail_format section(print) i added the following code:

Code:
If Me.verhoudingzand & "" = "" Then
Bijschrift247.Visible = False
Else
Bijschrift247.Visible = True
End If
If Me.verhoudingzand & "" = "" Then
Bijschrift252.Visible = False
Else
Bijschrift252.Visible = True
End If
If Me.verhoudingzand & "" = "" Then
Bijschrift248.Visible = False
Else
Bijschrift248.Visible = True
End If
If Me.verhoudingzand & "" = "" Then
Bijschrift251.Visible = False
Else
Bijschrift251.Visible = True
End If

Works like a charm!
 
Code:
If Me.verhoudingzand & "" = "" Then
     Bijschrift247.Visible = False
     Bijschrift252.Visible = False
     Bijschrift248.Visible = False
     Bijschrift251.Visible = False
Else
     Bijschrift247.Visible = True
     Bijschrift252.Visible = True
     Bijschrift248.Visible = True
     Bijschrift251.Visible = True
End If

What is Me.verhoudingzand supposed to contain?
 
Code:
If Me.verhoudingzand & "" = "" Then
     Bijschrift247.Visible = False
     Bijschrift252.Visible = False
     Bijschrift248.Visible = False
     Bijschrift251.Visible = False
Else
     Bijschrift247.Visible = True
     Bijschrift252.Visible = True
     Bijschrift248.Visible = True
     Bijschrift251.Visible = True
End If

What is Me.verhoudingzand supposed to contain?

Well, its basically a ratio of the sample content.

A sample consists of a % Asphalt and % sand.

Example : 70% Asphalt and 30% sand

But if the % Asphalt is 100 %, then the % sand is 0 obviously.

And if thats the case, then its no point of having the text

+ 0 % Sand

or +

(empty) % Sand

on the report.

Thats why i wanted to hide the labels, if verhoudingzand (% Sand) isNull.
 
I had a problem with this too! I have a report, which is a form letter, and at the bottom, I have a label that says "Additional Comments", where the user can enter a custom message.

If the custom message is blank, they wanted the additional comments to not show up.
So I wrote code to say, if the control is null, visibiliby of the label is false.

For some reason though, check on the "nullness" of the control fails. But it is null, because if I try to assign it's value to a varible, Access will throw an error.

The solution posted above does not work for me, Access throws an error message that my control has no value. If it has no value, why is the null check failing?
 
Last edited:
I found a solution to this. The problem is, the code was in the report_open event, and at that point in the process, Access doesn't know the state of any of the controls. I created a report_activate event, put the code in there, and it worked.
 

Users who are viewing this thread

Back
Top Bottom