Visible Property

  • Follow


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
0
Reply Utf 2/29/2008 4:19:04 PM

Harvard wrote:

>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 <> "")

-- 
Marsh
MVP [MS Access]
0
Reply Marshall 2/29/2008 5:39:35 PM

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" wrote:

> Harvard wrote:
> 
> >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 <> "")
> 
> -- 
> Marsh
> MVP [MS Access]
> 
0
Reply Utf 2/29/2008 6:28:04 PM

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]


Harvard wrote:
>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" wrote:
>
>> Harvard wrote:
>> 
>> >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 <> "")
0
Reply Marshall 2/29/2008 8:08:02 PM

3 Replies
441 Views

(page loaded in 0.048 seconds)


Reply: