Visible Property

H

Harvard

I have a report that has a "project" field. Sometimes the project field has
data in it, and sometimes it doesn't. I also have a running sum that counts
the number of projects. I want the running sum to be hidden when there is no
project corresponding to it. Currently, when no project is displayed, the
running sum is still set to "1."

This is what I've got so far...let me know if my logic is wrong...

=IIf([Project]<>"",[ProjectCounter].[Visible]=Yes,[ProjectCounter].[Visible]=No)

Thanks
 
M

Marshall Barton

Harvard said:
I have a report that has a "project" field. Sometimes the project field has
data in it, and sometimes it doesn't. I also have a running sum that counts
the number of projects. I want the running sum to be hidden when there is no
project corresponding to it. Currently, when no project is displayed, the
running sum is still set to "1."

This is what I've got so far...let me know if my logic is wrong...

=IIf([Project]<>"",[ProjectCounter].[Visible]=Yes,[ProjectCounter].[Visible]=No)


Setting property values is not something you can do in an
expression. You need to use VBA code to do it.

Put this kind of code in the Format event procedure of the
section that contains the text box:

Me.ProjectCounter.Visible = (Me.Project <> "")
 
H

Harvard

Maybe I did something wrong, but that didn't work. I'm using Access 2007. I
right-clicked "projectcounter" and then clicked "build event." from there, I
selected Code Builder. Then pasted the code that you told me to put...saved
it, and refreshed the report, but nothing happened. Did I do something wrong?

Marshall Barton said:
Harvard said:
I have a report that has a "project" field. Sometimes the project field has
data in it, and sometimes it doesn't. I also have a running sum that counts
the number of projects. I want the running sum to be hidden when there is no
project corresponding to it. Currently, when no project is displayed, the
running sum is still set to "1."

This is what I've got so far...let me know if my logic is wrong...

=IIf([Project]<>"",[ProjectCounter].[Visible]=Yes,[ProjectCounter].[Visible]=No)


Setting property values is not something you can do in an
expression. You need to use VBA code to do it.

Put this kind of code in the Format event procedure of the
section that contains the text box:

Me.ProjectCounter.Visible = (Me.Project <> "")
 
M

Marshall Barton

The Format event must be for the **section** containing the
text box. In my opinion, the event builder often guesses
worng about what event you want to create so you can easily
mess things up using that feature. Better to click in a
nlank are of the section near the text box and then find the
Format event **property**. Select [Event Procedure] from
the drop list and the use the [...] button to get to the
event **procedure** where you can enter the code.

If perchance all that is what you have, then you need to
investigate the code to make sure it is really doing what
you need it to do. For instance, you check if Project is
not "", are you sure the is not Null instead? Maybe you
should be using:

Me.ProjectCounter.Visible = Not IsNull(Me.Project)

or in unusual situations where it could be either "" or
Null:

Me.ProjectCounter.Visible = (Nz(Me.Project, "") <> "")
--
Marsh
MVP [MS Access]

Maybe I did something wrong, but that didn't work. I'm using Access 2007. I
right-clicked "projectcounter" and then clicked "build event." from there, I
selected Code Builder. Then pasted the code that you told me to put...saved
it, and refreshed the report, but nothing happened. Did I do something wrong?

Marshall Barton said:
Harvard said:
I have a report that has a "project" field. Sometimes the project field has
data in it, and sometimes it doesn't. I also have a running sum that counts
the number of projects. I want the running sum to be hidden when there is no
project corresponding to it. Currently, when no project is displayed, the
running sum is still set to "1."

This is what I've got so far...let me know if my logic is wrong...

=IIf([Project]<>"",[ProjectCounter].[Visible]=Yes,[ProjectCounter].[Visible]=No)


Setting property values is not something you can do in an
expression. You need to use VBA code to do it.

Put this kind of code in the Format event procedure of the
section that contains the text box:

Me.ProjectCounter.Visible = (Me.Project <> "")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top