Not Null

kitty77

Registered User.
Local time
Today, 06:25
Joined
May 27, 2019
Messages
719
I have a report (onload) that has four fields which are all NOT visible. I would like to make each field visible if the condition is met.

If IsNotNull([Mresults1]) And IsNull([Mresults2]) Then [Mresults1].Visible = True
If IsNotNull([Mresults2]) And IsNull([Mresults3]) Then [Mresults2].Visible = True
If IsNotNull([Mresults3]) And IsNull([Mresults4]) Then [Mresults3].Visible = True
If IsNotNull([Mresults4]) Then [Mresults4].Visible = True

Not sure I'm using the IsNotNull and IsNull properly.

Thanks.
 
IsNotNull() is not an intrinsic function. Did you write a custom function?

If Not IsNull([Mresults1]) And IsNull([Mresults2]) Then [Mresults1].Visible = True

Are you pulling multiple records in this report? Need to determine what will happen with each record when condition True or False? What you have will set all records the same. Consider:

Me.Mresults1.Visible = Not IsNull([Mresults1]) And IsNull([Mresults2])

And code would have to be in the Format event of Detail section which only executes for Print or PrintPreview.

Alternative is IIf() expression in textbox that just returns Null.
 
I'm pulling one record only.
 
Just to simplify... this could also work.

Code:
Mresults1.Visible = IsNull([Mresults2]) AND ( NOT IsNull([Mresults1])
Mresults2.Visible = IsNull([Mresults3]) AND ( NOT IsNull([Mresults2])
Mresults3.Visible = IsNull([Mresults4]) AND ( NOT IsNull([Mresults3])
Mresults4.Visible = Not IsNull([Mresults4])

Your IF/THEN sequences were NOT WRONG. But this is a slightly more efficient way based on the theory that you have to compute the T/F value of the expressions to power the IF decision anyway - so instead use it directly in assigning the T/F result.
 
Just to simplify... this could also work.

Code:
Mresults1.Visible = IsNull([Mresults2]) AND ( NOT IsNull([Mresults1])
Mresults2.Visible = IsNull([Mresults3]) AND ( NOT IsNull([Mresults2])
Mresults3.Visible = IsNull([Mresults4]) AND ( NOT IsNull([Mresults3])
Mresults4.Visible = Not IsNull([Mresults4])

Your IF/THEN sequences were NOT WRONG. But this is a slightly more efficient way based on the theory that you have to compute the T/F value of the expressions to power the IF decision anyway - so instead use it directly in assigning the T/F result.
Thank You!
 
Pat, OP specified code for a report, not a form.
 
The OP also said the report had only one record to display
 

Users who are viewing this thread

Back
Top Bottom