Making Textbox Invisible When Null on a Report

grubnz

Registered User.
Local time
Today, 02:19
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]
 
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
 
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

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
 
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

Post a stripped version on you database with some sample data, (zip it)
 
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

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
 
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
 
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.
 
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

Back
Top Bottom