Using a Sub to make Items Invisible

V

vtj

Is it possible using an 'on format' procedure to change the visible property
to false for a report? I have tried "Me.Line31.Visible = False" and "Set
Me.Line31.Visible = False" statements in the sub and neither works. I have
also tried '!' instead of the '.' for separators but that makes no
difference. I am doing this in a Private Sub GroupFooter6_Format(Cancel As
Integer, FormatCount As Integer) titled sub and it has an End Sub command and
is for GroupFooter6 on the report. There are several items (lines, text
boxes, fields, etc.) in the footer but if I can make one invisible, I should
be able to make them all invisible.
 
J

John Spencer

This line should work if there is a Control named line31 in the groupfooter.
Me.Line31.Visible = False

Please post the entire sub. Are you changing the visibility based on some
condition? If so what is the condition?

For instance the following won't work as expected

If Me.Text20 = Null then
Me.Line31.Visible = false
else
Me.Line31.visible = true
End If

Me.Text20 = Null is always go to trigger the second condition -
me.Line31.visible because nothing is ever equal to null and that includes nulls.

The test should be
If IsNull(Me.Text20) Then

Or optionally
IF Len(Me.Text20 & "") = 0 Then
...
else
...
end if


John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County
 
V

vtj

Thank you for your reply. Here is the entire Sub. Private Sub
GroupFooter6_Format(Cancel As Integer, FormatCount As Integer)
Me.Line31.Visible = False
Me.Line33.Visible = False
Me.Line35.Visible = False
Me.Field23.Visible = False
Me.Field24.Visible = False
Me.Field55.Visible = False
Me.Text114.Visible = False
Me.Text115.Visible = False
Me.Text116.Visible = False
Me.[revenue-expense ind budget].Visible = False
End Sub


Each of the lines are one line in the sub - no line continuations. I am
thinking that should make all of the items invisible but it does the same
thing as if this sub were not there. In the GroupFooter6 properties there is
an [Event Procedure] with the 3 dots that when clicked take me to the sub
above. It is probably something simple as I am not VBA proficient. I
thought I could step through and use the immediate window to see that
something would happen when run but can't seem to do that either.
 
J

John Spencer

The code looks like it should ALWAYS hide those items. So I suspect that you
have some corruption in the database. Especially if you never see this code run.

Try Allen Browne's article on Recovering from Corruption at:
http://allenbrowne.com/ser-47.html

Also you take a look at Tony Toews site
http://www.granite.ab.ca/access/corruptmdbs.htm

John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County
Thank you for your reply. Here is the entire Sub. Private Sub
GroupFooter6_Format(Cancel As Integer, FormatCount As Integer)
Me.Line31.Visible = False
Me.Line33.Visible = False
Me.Line35.Visible = False
Me.Field23.Visible = False
Me.Field24.Visible = False
Me.Field55.Visible = False
Me.Text114.Visible = False
Me.Text115.Visible = False
Me.Text116.Visible = False
Me.[revenue-expense ind budget].Visible = False
End Sub


Each of the lines are one line in the sub - no line continuations. I am
thinking that should make all of the items invisible but it does the same
thing as if this sub were not there. In the GroupFooter6 properties there is
an [Event Procedure] with the 3 dots that when clicked take me to the sub
above. It is probably something simple as I am not VBA proficient. I
thought I could step through and use the immediate window to see that
something would happen when run but can't seem to do that either.

John Spencer said:
This line should work if there is a Control named line31 in the groupfooter.
Me.Line31.Visible = False

Please post the entire sub. Are you changing the visibility based on some
condition? If so what is the condition?

For instance the following won't work as expected

If Me.Text20 = Null then
Me.Line31.Visible = false
else
Me.Line31.visible = true
End If

Me.Text20 = Null is always go to trigger the second condition -
me.Line31.visible because nothing is ever equal to null and that includes nulls.

The test should be
If IsNull(Me.Text20) Then

Or optionally
IF Len(Me.Text20 & "") = 0 Then
...
else
...
end if


John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County
 

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