Visibility of Report controls based on null or not null

Leesha
BronzeLounger
Posts: 1484
Joined: 05 Feb 2010, 22:25

Visibility of Report controls based on null or not null

Post by Leesha »

Hi,
I have a report that is being used for a paper invoice format. There are boxes drawn on it for the user to place a check in if they wish to order the item. I didn't use the checkbox control because I didn't like the size or the the look. When the report loads, there are times when a control that contains the sale price won't have any data. This is correct. When this happens, the box should be not visible. I tried coding this but nothing is working. This is what I tried on the no data event and on the on open evert but neither worked.

If IsNull(Me.SumOfWood) Then
Me.box2.Visible = False
ElseIf Not IsNull(Me.SumOfWood) Then
Me.box2.Visible = True
End If

What am I missing or is this even possible?
Thanks!
Leesha

User avatar
HansV
Administrator
Posts: 78235
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Visibility of Report controls based on null or not null

Post by HansV »

If SumOfWood is in the Detail section of the report, you should place the code in the On Format event of the Detail section:

Code: Select all

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
    Me.Box2.Visible = Not IsNull(Me.SumOfWood)
End Sub
Best wishes,
Hans

Leesha
BronzeLounger
Posts: 1484
Joined: 05 Feb 2010, 22:25

Re: Visibility of Report controls based on null or not null

Post by Leesha »

Thanks Hans, that worked perfectly! I didn't realize that there were events on the sections of the report.

Thanks,
Leesha

Egg 'n' Bacon
5StarLounger
Posts: 736
Joined: 18 Mar 2010, 11:05

Re: Visibility of Report controls based on null or not null

Post by Egg 'n' Bacon »

How can this be used when based on the value of a control?

User avatar
HansV
Administrator
Posts: 78235
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Visibility of Report controls based on null or not null

Post by HansV »

Could you give an example of what you have in mind?
Best wishes,
Hans

Egg 'n' Bacon
5StarLounger
Posts: 736
Joined: 18 Mar 2010, 11:05

Re: Visibility of Report controls based on null or not null

Post by Egg 'n' Bacon »

Silly I know, but I'm just not getting the syntax :groan:

Following on from my other thread, I would like 2 (report) controls/fields to remain hidden if a third ([InciLevel]) has a value of "RIDDOR".

User avatar
HansV
Administrator
Posts: 78235
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Visibility of Report controls based on null or not null

Post by HansV »

Your previous thread was about a form. On a report, you have to use the On Format event of the section that contains the controls; I assume the Detail section

Code: Select all

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
    Me.RIDDORdate.Visible = Not (Me.InciLevel = "RIDDOR")
    Me.RIDDORno.Visible = Not (Me.InciLevel = "RIDDOR")
End Sub
Best wishes,
Hans

Egg 'n' Bacon
5StarLounger
Posts: 736
Joined: 18 Mar 2010, 11:05

Re: Visibility of Report controls based on null or not null

Post by Egg 'n' Bacon »

Thank you Hans. Once again you've helped me out.