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.
10 16654
Could this be done by changing the 'Can Shrink' property of the appropriate field to 'Yes'?
Hi Hedges98 - I tried that, however I did not see anything changing.
Thank you.
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
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.
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. - 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
-
Dim dblStart As Double
-
Dim dblLength As Double
-
Dim ctlControl As Control
-
Dim dblL As Double
-
Dim dblMinWidth As Double
-
Dim dblWidth As Double
-
-
dblMinWidth = 0.025
-
-
On Error GoTo cswArrangeColumns_Error
-
' dblWidth = C1.Width
-
' If dblWidth = 0 Then dblWidth = dblMinWidth
-
dblL = C1.Left + C1.Width
-
C2.Left = C1.Left + C1.Width
-
dblL = C2.Width + dblL
-
C3.Left = C2.Left + C2.Width
-
dblL = C3.Width + dblL
-
C4.Left = C3.Left + C3.Width
-
dblL = C4.Width + dblL
-
C5.Left = C4.Left + C4.Width
-
dblL = C5.Width + dblL
-
C6.Left = C5.Left + C5.Width
-
dblL = C6.Width + dblL
-
C7.Left = C6.Left + C6.Width
-
dblL = C7.Width + dblL
-
C8.Left = C7.Left + C7.Width
-
dblL = C8.Width + dblL
-
C9.Left = C8.Left + C8.Width
-
dblL = C9.Width + dblL
-
C10.Left = C9.Left + C9.Width
-
dblL = C10.Width + dblL
-
C11.Left = C10.Left + C10.Width
-
dblL = C11.Width + dblL
-
C12.Left = C11.Left + C11.Width
-
Dim strName As String
-
' strName = C12.Name
-
dblL = C12.Width + dblL
-
C13.Left = C12.Left + C12.Width
-
dblL = C13.Width + dblL
-
C14.Left = C13.Left + C13.Width
-
dblL = C14.Width + dblL
-
C15.Left = C14.Left + C14.Width
-
dblL = C15.Width + dblL
-
C16.Left = C15.Left + C15.Width
-
dblL = C16.Width + dblL
-
C17.Left = C16.Left + C16.Width
-
dblL = C17.Width + dblL
-
C18.Left = C17.Left + C17.Width
-
dblL = C18.Width + dblL
-
C19.Left = C18.Left + C18.Width
-
dblL = C19.Width + dblL
-
C20.Left = C19.Left + C19.Width
-
dblL = C20.Width + dblL
-
C21.Left = C20.Left + C20.Width
-
dblL = C21.Width + dblL
-
C22.Left = C21.Left + C21.Width
-
dblL = C22.Width + dblL
-
C23.Left = C22.Left + C22.Width
-
dblL = C23.Width + dblL
-
C24.Left = C23.Left + C23.Width
-
dblL = C24.Width + dblL
-
C25.Left = C24.Left + C24.Width
-
dblL = C25.Width + dblL
-
C26.Left = C25.Left + C25.Width
-
dblL = C26.Width + dblL
-
C27.Left = C26.Left + C26.Width
-
dblL = C27.Width + dblL
-
C28.Left = C27.Left + C27.Width
-
dblL = C28.Width + dblL
-
C29.Left = C28.Left + C28.Width
-
dblL = C29.Width + dblL
-
C30.Left = C29.Left + C29.Width
-
dblL = C30.Width + dblL
-
Exit_cswArrangeColumns:
-
cswArrangeColumns = dblL
-
On Error GoTo 0
-
Exit Function
-
-
cswArrangeColumns_Error:
-
GoTo Exit_cswArrangeColumns
-
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 - dim intWidth as integer
-
c2.left = c1.left ' added in case c2 is invisible
-
intWidth = c1.width
-
if c2.visible then ' add this to ea object to elim gaps for invisibles
-
' only change col2's position if it is visible
-
C2.Left = C1.Left + intWidth ' changed to intWidth from C1.width
-
intWidth = c2.width ' add this to ea obj
-
dblL = C2.Width + dblL ' only increase add to the line's length if it is visible
-
endif
-
Then repeat that for all remaining columns. Really would be better done as an array with a loop.
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.
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
Sign in to post your reply or Sign up for a free account.
Similar topics |
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,
|
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...
|
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...
|
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...
|
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...
| |
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),...
|
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...
|
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
...
|
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...
|
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...
|
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...
| |
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...
|
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...
|
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...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
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...
| |