Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Null fields in a report 1

Status
Not open for further replies.

bradley1122

Technical User
Mar 22, 2005
2
US
This is interesting. I have some fields in a report that I would like to hide. If one field_1 is empty than I want to hide field_2. My code checks to see if field_1 in the "detail" is null and if so then it hides field_2:

If IsNull(field_1.Value)
Then field_2.Visible = False
Else field_2.Visible = True
End if

The code refuses to work. I am wondering...is a field that is empty in an access report really null? I have assumed that these empty fields are null...if I was mistaken then my code would be wrong.

Any Help Appreciated,
Bradley
 
The If-Then-Else construct should look something like this:

[tt]If IsNull(field_1.Value) Then
field_2.Visible = False
Else
field_2.Visible = True
End if[/tt]

But one of the issues, could be that there is something in the controls, so they are not Null but "". Here's a test that should detect that too:

[tt]me!field_2.Visible = (trim$(me!field_1.Value & "")<>"")[/tt]

Roy-Vidar
 
Roy,

This was indeed the problem. My Empty field was not null, and instead = "". I set my code to be the following:

If field_1.Value="" Then
field_2.Visible = False
Else
field_2.Visible = True
End if
And it worked well.

Thanks for your help!
Bradley
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top