Making Textbox Invisible When Null on a Report (1 Viewer)

grubnz

Registered User.
Local time
Today, 01:11
Joined
Sep 12, 2011
Messages
41
Hi there,

I have been trying to figure out how to make a textbox if it is null to be invisible on a report.
My experience in programming is somewhat limited so any help is greatly appreciated. This is one of the ways I have tried but I maybe on the wrong track.

I selected the detail section on the report, under the Event tab, On Format option then selected [Event Procedure] and then clicked on the ellipses.


Tbl_Receipt_Description is the name of the text box.
*******************************************
If Me.Tbl_Receipt_Description = “ ” then
Me.Tbl_Receipt_Description.Visible = False
Else
Me.Tbl_Receipt_Description.Visible = True
End If
*******************************************
:confused:
[FONT=&quot]Thanking anyone who is able to help with this it is greatly appreciated.[/FONT]
 

pr2-eugin

Super Moderator
Local time
Today, 09:11
Joined
Nov 30, 2011
Messages
8,494
Try the On Load event of the Report..
Code:
Private Sub Report_OnLoad()
    Me.Tbl_Receipt_Description.Visible = Len(Me.Tbl_Receipt_Description & vbNullString) <> 0 
End Sub
 

grubnz

Registered User.
Local time
Today, 01:11
Joined
Sep 12, 2011
Messages
41
Hi Paul,

Firstly I would like to thank you for your time in helping me. :)

It worked but it hid all the fields including the ones that had text.

I have attached what happen when I carried out using the code below.

Thank you once again.

Have a wonderful weekend. :)
 

Attachments

  • Qry_CompleteIncomeExpenditureStatement_2013_11_01_.pdf
    65.4 KB · Views: 95

JHB

Have been here a while
Local time
Today, 10:11
Joined
Jun 17, 2012
Messages
7,732
Try by moving the code from pr2-eugin to where you had the code before, in the detail section on the report, On Format option.

Code:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
  Me.Tbl_Receipt_Description.Visible = Len(Me.Tbl_Receipt_Description & vbNullString) <> 0
End Sub
 

grubnz

Registered User.
Local time
Today, 01:11
Joined
Sep 12, 2011
Messages
41
Hi JHB,

Thanking you for your response. Sorry I haven't responded earlier.

I have tried as suggested On format option, also I tried putting it under on Current and On No Data just in case.

But when I put it under the On format option or any of the others I have tried. It remains the same nothing is hidden.

I hope that makes sense.

Thank you once again for your assistance.

Have a lovely day. :)
 

Attachments

  • Qry_CompleteIncomeExpenditureStatement_2013_11_05.pdf
    77.2 KB · Views: 88

JHB

Have been here a while
Local time
Today, 10:11
Joined
Jun 17, 2012
Messages
7,732
Post a stripped version on you database with some sample data, (zip it)
 

grubnz

Registered User.
Local time
Today, 01:11
Joined
Sep 12, 2011
Messages
41
Hi JHB,

I have attached the sample it is the only select query and report in the database.

Qry_CompleteIncomeExpenditureReport - Query and Report Name.

Thank you and have a wonderful day. :)
 

Attachments

  • SnookerAccountsTesting_2013_11_07_1.zip
    177.5 KB · Views: 86

stopher

AWF VIP
Local time
Today, 09:11
Joined
Feb 1, 2006
Messages
2,395
You could just change the "Can Shrink" property for the relevant text boxes to YES. If you do this then if there is null text then the boxes disappear.

hth
Chris
 

stopher

AWF VIP
Local time
Today, 09:11
Joined
Feb 1, 2006
Messages
2,395
I think the problem with the solution provided by JHB/Pr2-eugin is to do with your naming convention.

The control you are referencing as Tbl_Receipt_Description is actually named Tbl_Receipt.Description (note the full stop insteads of underscore). If you rename the control to Tbl_Receipt_Description then it should work fine.

Chris
 

grubnz

Registered User.
Local time
Today, 01:11
Joined
Sep 12, 2011
Messages
41
Hi Chris,

Thank you for telling me about the Shrink Property it worked. :)

I will also try spending more time on trying to get the code to work taking into account your suggestion of the dot rather than dash and the other suggestions in this post. When I am not tired ;)

I would just like to say thank you to you, Paul and JHB as you have given your time to help me.

Have a lovely day.
 

grubnz

Registered User.
Local time
Today, 01:11
Joined
Sep 12, 2011
Messages
41
Hi Paul,

Thank you for the naming convention post from now on I will use this naming convention. It will make things simpler. :)

Have a wonderful day.

Regards,

Annie
 

Users who are viewing this thread

Top Bottom