473,545 Members | 1,956 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Hide fields in a report which do not have data

33 New Member
Is there a way to hide fields in a report that do not have any data. I have few fields that have images and I would like to hide them as well whenever there is none. I am using Access 07.
Feb 26 '10 #1
10 16654
hedges98
109 New Member
Could this be done by changing the 'Can Shrink' property of the appropriate field to 'Yes'?
Feb 26 '10 #2
mulamootil
33 New Member
Hi Hedges98 - I tried that, however I did not see anything changing.

Thank you.
Feb 26 '10 #3
jimatqsi
1,273 Recognized Expert Top Contributor
In the format event, if the field is empty set the field's visible property to false
Assuming this is in the report detail, this code would be in the Detail section's format event

if isnull(me!field name) then
me!fieldname.vi sible = false
else
me!fieldname.vi sible = true
endif
Feb 26 '10 #4
mulamootil
33 New Member
Thank you so much. That was a great help. It worked just perfect. Formatting an Access report is really a pain. It still leaves huge gaps in my report and sometimes overlaps fields, but it definitely hides all the fields no data. Thanks again.
Mar 2 '10 #5
hedges98
109 New Member
To prevent the gaps, you could play around with the Can Shrink property I mentioned. Take a look at this for more information: http://support.microsoft.com/kb/299011
Mar 2 '10 #6
jimatqsi
1,273 Recognized Expert Top Contributor
Unfortunately, as that article mentions, can shrink only eliminates vertical white space, not horizontal white space. So in this case, if mulamootil made a column invisible, unsightly gaps across the line will appear.

Access report setup can be a pain. A little extra work goes a long way, though, to making a good result. I wrote this routine that I use to align columns perfectly next to each other. Mulamootil, you could alter this a little bit by adding a test for each column; if it is visible you include it in the placement of columns, if it is not visible, you can not add its width to the progression across the page.

There's additional room for improvement here. Probably an array of object names should be passed instead of a list of individual objects (text boxes and labels). Note that the first column object is not placed by this code, it is assumed to be the starting point. Here's the code, which belongs in the .format event.

Expand|Select|Wrap|Line Numbers
  1. Public Function cswArrangeColumns(Optional C1, Optional C2, Optional C3, Optional C4, Optional C5, Optional C6, Optional C7, Optional C8, Optional C9, Optional C10, Optional C11, Optional C12, Optional C13, Optional C14, Optional C15, Optional C16, Optional C17, Optional C18, Optional C19, Optional C20, Optional C21, Optional C22, Optional C23, Optional C24, Optional C25, Optional C26, Optional C27, Optional C28, Optional C29, Optional C30) As Double
  2. Dim dblStart As Double
  3. Dim dblLength As Double
  4. Dim ctlControl As Control
  5. Dim dblL As Double
  6. Dim dblMinWidth As Double
  7. Dim dblWidth As Double
  8.  
  9. dblMinWidth = 0.025
  10.  
  11.    On Error GoTo cswArrangeColumns_Error
  12. '        dblWidth = C1.Width
  13. '        If dblWidth = 0 Then dblWidth = dblMinWidth
  14.         dblL = C1.Left + C1.Width
  15.         C2.Left = C1.Left + C1.Width
  16.         dblL = C2.Width + dblL
  17.         C3.Left = C2.Left + C2.Width
  18.         dblL = C3.Width + dblL
  19.         C4.Left = C3.Left + C3.Width
  20.         dblL = C4.Width + dblL
  21.         C5.Left = C4.Left + C4.Width
  22.         dblL = C5.Width + dblL
  23.         C6.Left = C5.Left + C5.Width
  24.         dblL = C6.Width + dblL
  25.         C7.Left = C6.Left + C6.Width
  26.         dblL = C7.Width + dblL
  27.         C8.Left = C7.Left + C7.Width
  28.         dblL = C8.Width + dblL
  29.         C9.Left = C8.Left + C8.Width
  30.         dblL = C9.Width + dblL
  31.         C10.Left = C9.Left + C9.Width
  32.         dblL = C10.Width + dblL
  33.         C11.Left = C10.Left + C10.Width
  34.         dblL = C11.Width + dblL
  35.         C12.Left = C11.Left + C11.Width
  36.         Dim strName As String
  37.      '   strName = C12.Name
  38.         dblL = C12.Width + dblL
  39.         C13.Left = C12.Left + C12.Width
  40.         dblL = C13.Width + dblL
  41.         C14.Left = C13.Left + C13.Width
  42.         dblL = C14.Width + dblL
  43.         C15.Left = C14.Left + C14.Width
  44.         dblL = C15.Width + dblL
  45.         C16.Left = C15.Left + C15.Width
  46.         dblL = C16.Width + dblL
  47.         C17.Left = C16.Left + C16.Width
  48.         dblL = C17.Width + dblL
  49.         C18.Left = C17.Left + C17.Width
  50.         dblL = C18.Width + dblL
  51.         C19.Left = C18.Left + C18.Width
  52.         dblL = C19.Width + dblL
  53.         C20.Left = C19.Left + C19.Width
  54.         dblL = C20.Width + dblL
  55.         C21.Left = C20.Left + C20.Width
  56.         dblL = C21.Width + dblL
  57.         C22.Left = C21.Left + C21.Width
  58.         dblL = C22.Width + dblL
  59.         C23.Left = C22.Left + C22.Width
  60.         dblL = C23.Width + dblL
  61.         C24.Left = C23.Left + C23.Width
  62.         dblL = C24.Width + dblL
  63.         C25.Left = C24.Left + C24.Width
  64.         dblL = C25.Width + dblL
  65.         C26.Left = C25.Left + C25.Width
  66.         dblL = C26.Width + dblL
  67.         C27.Left = C26.Left + C26.Width
  68.         dblL = C27.Width + dblL
  69.         C28.Left = C27.Left + C27.Width
  70.         dblL = C28.Width + dblL
  71.         C29.Left = C28.Left + C28.Width
  72.         dblL = C29.Width + dblL
  73.         C30.Left = C29.Left + C29.Width
  74.         dblL = C30.Width + dblL
  75. Exit_cswArrangeColumns:
  76.     cswArrangeColumns = dblL
  77.     On Error GoTo 0
  78.    Exit Function
  79.  
  80. cswArrangeColumns_Error:
  81.     GoTo Exit_cswArrangeColumns
  82.  
Mar 2 '10 #7
jimatqsi
1,273 Recognized Expert Top Contributor
To eliminate the gaps from the invisibles you could either avoid including the invisibles in the call to the function, or more elegantly, you could make the function smart enough to avoid including them in the movement across the page. I'd change the function like this
Expand|Select|Wrap|Line Numbers
  1. dim intWidth as integer
  2.        c2.left = c1.left       ' added in case c2 is invisible
  3.        intWidth = c1.width
  4.        if c2.visible then    ' add this to ea object to elim gaps for invisibles
  5.                                  ' only change col2's position if it is visible
  6.          C2.Left = C1.Left + intWidth ' changed to intWidth from C1.width
  7.          intWidth = c2.width      ' add this to ea obj 
  8.          dblL = C2.Width + dblL  ' only increase add to the line's length if it is visible
  9.        endif 
  10.  
Then repeat that for all remaining columns. Really would be better done as an array with a loop.
Mar 2 '10 #8
jimatqsi
1,273 Recognized Expert Top Contributor
One more note to state the obvious, you would call this to format both the headings and the detail or totals that should appear in those columns.
Mar 2 '10 #9
mulamootil
33 New Member
Thanks Jimatqsi and Hedges98. I haven't gotten a chance to try this yet, however I sure see the light at the end of the tunnel. I will let you know the outcome. Again, I appreciate the input and thank you for the code Jim.

Stan
Mar 4 '10 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

1
19141
by: Stephan | last post by:
Hi, I'm using Visual Studio 2003 (C#) with the integrated Crystal Report software and have the following question: How can I assign a value (string) to an unbound (string) field in Crystal Report at runtime? Example: private void button1_Click(object sender,
3
3689
by: CSDunn | last post by:
Hello, I have a situation with MS Access 2000 in which I need to display report data in spreadsheet orientation (much like a datasheet view for a form). If you think of the report in terms of what a spreadsheet might show, the column names will actually be dynamic, based on data from a SQL Server 2000 database. The row data will also come...
1
362
by: Sharon Frederick | last post by:
I was hoping to get an answer to the following problem. In a report that I run I get lots of duplicate fields when I only want to show one of each. I have said yes to the hide duplicates field and this does show only one of each record but leaves spaces where the original data was. This means the report looks awful. How can I get rid of the...
3
10616
by: google | last post by:
I have a database with four table. In one of the tables, I use about five lookup fields to get populate their dropdown list. I have read that lookup fields are really bad and may cause problems that are hard to find. The main problem I am having right now is that I have a report that is sorted by one of these lookup fields and it only displays...
2
1908
by: Darryl Kerkeslager | last post by:
As the subject above hopefully makes clear, I want to do several reports, "with lots of fields not otherwise in database". These reports also have variable-length text. I have defined the following options (all users have Office 2000): 1. All Access solution. This appears to involve creating forms to enter data that is just put into a...
7
4526
by: Darin | last post by:
I have a report that sub-totals on a group, then grand-totals at the report footer. If there's only one group, the sub-total and grand total are redundant, so I only want to show one of them. I know how to count the groups, then hide the report footer if there's only one group, but my problem is I want to hide the group footer (sub-total),...
5
2763
by: ken | last post by:
Hi, Lets say you have a report with 10 rows. The first 4 of them have duplicate values in a given field. So you set the Hide Duplicates property to Yes and when you preview the report it shows you the first value and the next 3 fields are blank(hidden using hide duplicates). I was wondering if there was some way for me to set a value to those...
1
3406
by: Neekos | last post by:
I have a report that shows information for up to 5 passengers per booking. Not every booking has all 5 passengers in it, so i dont want those fields showing up on my report. How can i get rid of these? I tried: Private Sub Report_Open(Cancel As Integer) If IsNull() Then Me.Pax2.Visible = False Me.Grats2.Visible = False ...
10
11733
by: sara | last post by:
Hi - Is it possible to hide the detail section of a report at run time? I have a report that prints all details, with summary lines. The user would like the report ALSO with just summary lines. It seems the simplest thing is to run the code (see below) once with the detail section showing, and a second time hiding the detail section. I...
24
3102
by: vsts2007 | last post by:
Hi, I am new to ms-access, i need some help on reports. I prepared payroll transactions for staff in which there are 14 fields. I want to hide some fields which has no data (only zeros). I want to write a code to whole report not for a particular field. If should appear when some data is there not zeros. can somebody help me out in this...
0
7484
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7415
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7928
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7775
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
4963
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3470
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3451
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1030
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
726
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.