473,325 Members | 2,860 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

Access Report: Hiding field and Label when field is null

Hi all:

On Access 2003: I have a tabular form with labels next to the associated fields. I'd like them both to dissappear when the associated field is null. ("Can Shrink" will do this for the field, but the label is still there, so the report does not shrink.)

Any ideas how I can make the label shrink too?

Thanks,
Jun 15 '09 #1
13 44137
ChipR
1,287 Expert 1GB
Simply change the label to a text box with no backcolor, and set conditional formatting so that if the value is null ( or [control] = "" ), the text is the same color as the background. You will want to lock and disable the text box so the text can't be selected when it is not supposed to be visible.
Jun 16 '09 #2
Thanks.

Actually, I found a different answer: I changed the label to a text box and set the control source to iif(isnull([related control]),null,"Label Title"). Then I set the Can Shrink properties for the label and the related to control to Yes.
Jun 16 '09 #3
ChipR
1,287 Expert 1GB
Thank you for sharing your solution. That's probably a much better idea, since I've experienced slow updating with conditional formatting.
Jun 16 '09 #4
NeoPa
32,556 Expert Mod 16PB
Each section in a report has a Format event. You could handle this without any special usages of controls simply by setting the .Visible property of both controls to (Not IsNull(Me.Control)).
Jun 17 '09 #5
ChipR
1,287 Expert 1GB
Ah, I was thinking of continuous forms. Would the Format event work in that case? Forgive my laziness in not trying it myself, but I think it's quicker to ask.
Jun 17 '09 #6
NeoPa
32,556 Expert Mod 16PB
@ChipR
Not at all. Happy to answer.

I believe the Format event is specific to Report sections and is not available anywhere I can find for forms.
Jun 17 '09 #7
NeoPa,

I admit I'm baffled. (I'm only a programmer by circumstance, not by training.) Note, I'm using Access 2003.

1: What's the "Format event". Is that the format tab in the properties of the form?
2: I can't put that code in dialog box for Is Visible -- it limits me to Yes and No

Can you explain? Thanks.
Jun 17 '09 #8
NeoPa
32,556 Expert Mod 16PB
I will be happy to. Unfortunately, I will need to be careful to explain it in terms that make sense to you which will take time I don't have immediately available.

If you see nothing by tomorrow bump the thread and I'll post a proper explanation.
Jun 17 '09 #9
NeoPa,

Thanks for the offer, but it's not necessary; I have a solution that works. But if you're willing to give me 3 or 4 minutes, (and no more) I'd like to understand where to put the code you suggest -- do I go into code builder and build a sub called control_format(...); if so, is it attached to the control or to the form definition?


Thanks,


Dante
Jun 17 '09 #10
NeoPa
32,556 Expert Mod 16PB
OK. Here goes. A little intro to programming in VBA and the structures you can work with.

Most code in VBA is instigated by events. There are various objects (such as forms; reports; controls on either forms or reports; etc; etc). Typically objects have various events associated with them. An event can be considered as a trigger for starting specific relevant code - generally termed an Event Handler Procedure.

I won't go into too much detail of all the possible events for all the possible objects as they are really far too numerous to mention. To put this in context though, a report has various sections, each of which has a Format event associated with them. Forms don't have any objects with a Format event as far as I'm aware, so this should be considered exclusively for reports.

When assigning code to an event, what you need to do is the following (to start you off right) :
  1. Open the containing object in Design Mode (if the object is a form or report then it won't be contained).
  2. Select the object (control; section; etc).
  3. Show Properties and select the Event from the list.
  4. The value will have a drop-down and the value "[Event Procedure]" will be available. Select this and click on the ellipsis button to the right.
  5. This will switch to the IDE (Integrated Development Environment) and create a procedure shell for you to populate with your code.
Jun 18 '09 #11
Thank you NeoPa. You helped me find the one piece of the puzzle that I was missing. I'd been looking for the events associated with the controls, or at the form level, but not at the detail section level. Now I see the "on Format" event.

Thanks again.


Dante
Jun 18 '09 #12
NeoPa
32,556 Expert Mod 16PB
Pleased to help Dante, though still a little curious that you refer only to Forms when talking about the Format event. You do appreciate that this is fundamentally Report related rather than anything to do with Forms as such?
Jun 18 '09 #13
My mistake; I meant reports.

Thanks again
Jun 18 '09 #14

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

Similar topics

2
by: c.anandkumar | last post by:
Hi All - I have some problems getting a small piece of javascript working correctly for Firefox. Here is what I am trying to do - 1. I have a form (like a search form) 2. I have many groups...
2
by: Galina | last post by:
Hello I have a report, which lists records. Each record has money paid field. Money paid can be 0 or not 0. I calculate and print summary of money for a group in the group footer, as well as...
9
by: Colin McGuire | last post by:
Hi, I have an report in Microsoft Access and it displays everything in the table. One column called "DECISION" in the table has either 1,2, or 3 in it. On my report it displays 1, 2, or 3. I want...
5
by: Max ©® | last post by:
Hi all, I'm going crazy... I've report with subreport. I want simply move some objects on report and subreport according to fields value. For example I want hide a label when a field is empty. ...
2
by: Coll | last post by:
I have a field that I would like to display on a report only if the value of another field matches a certain criteria. If it does match I need the label & the field value to display (though I'm...
9
by: prakashwadhwani | last post by:
Hi !! I'm about to develop a new project for a client. Should I go about it in Access 2003 or 2007 ? Purchasing it either for me or for my client is not a major consideration here ... what I'd...
1
by: zufie | last post by:
I receive the # Error when I run my Mailing Label report. I generated the report using Label Wizard. The # Error appears in the Name field portion of the Label. My report is based on a...
2
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.