Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Reports / Printing / April 2008

Tip: Looking for answers? Try searching our database.

Can't Hide Text Box

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Keith Wilby - 28 Apr 2008 11:34 GMT
I have the following code in a report's group footer:

Private Sub GroupFooter0_Format(Cancel As Integer, FormatCount As Integer)

If Me.txtMaterials = "" Then
   Me.txtMaterials.Visible = False
   Me.txtMatHead.Visible = False
End If

End Sub

The idea is that, if the Materials field is empty, the text boxes are hidden
and the controls beneath "move up" the report at run-time.  However, when I
run the report only txtMaterials is hidden and txtMatHead remains visible.
If I change txtMatHead's control source to the same one as txtMaterials it
behaves as expected and is hidden.  What am I missing here?

Thanks.

Keith.
John Spencer - 28 Apr 2008 12:48 GMT
I think you need to change the expression to check for Null values (which are
not the same as zero length string values ("").

Private Sub GroupFooter0_Format(Cancel As Integer, FormatCount As Integer)

If Len(Me.txtMaterials & "") = 0 Then
   Me.txtMaterials.Visible = False
   Me.txtMatHead.Visible = False
End If

End Sub

Or
Private Sub GroupFooter0_Format(Cancel As Integer, FormatCount As Integer)

If IsNull(Me.txtMaterials) Then
   Me.txtMaterials.Visible = False
   Me.txtMatHead.Visible = False
End If

End Sub

That will cause you a problem because you never set the visible property to
true if Me.TxtMaterials has a value.  So once the group footer set the
controls visibility to False then it will stay that way for the rest of the
report.

I might use one of the alternatives below

 Me.txtMaterials.Visible = Not IsNull(Me.txtMaterials)
 me.txtMatHead.Visible = Not IsNull(Me.txtMaterials)
Or use
 Me.txtMaterials.Visible = Len(Me.txtMaterials & "")>0
 me.txtMatHead.Visible = Len(Me.txtMaterials & "")>0

John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County

> I have the following code in a report's group footer:
>
[quoted text clipped - 17 lines]
>
> Keith.
Keith Wilby - 28 Apr 2008 13:06 GMT
>I think you need to change the expression to check for Null values (which
>are not the same as zero length string values ("").

<snip>

<slaps forehead>

Thanks very much John, works a treat.  I don't know why I got it into my
head that I had to check for ZLS and not nulls.  One of those days.  Strange
how it "half" worked though.

Thanks again.

Regards,
Keith.
John Spencer - 28 Apr 2008 15:27 GMT
I'm guessing that it half-worked because you had the control's can shrink
property set to true.  I could definitely be wrong though, since I obviously
have no idea how you set up the report.

John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County

>> I think you need to change the expression to check for Null values
>> (which are not the same as zero length string values ("").
[quoted text clipped - 11 lines]
> Regards,
> Keith.
Keith Wilby - 28 Apr 2008 15:47 GMT
> I'm guessing that it half-worked because you had the control's can shrink
> property set to true.  I could definitely be wrong though, since I
> obviously have no idea how you set up the report.

That would explain it, yes.

Many thanks John.
Evi - 28 Apr 2008 19:39 GMT
You may also need to add to your code

If Len(Me.txtMaterials & "") = 0 Then
    Me.txtMaterials.Visible = False
   Me.txtMatHead.Visible = False
Else
    Me.txtMaterials.Visible = True
   Me.txtMatHead.Visible = True

End If

I don't know about later versions, but in Acc97, if I omitted the Else,  the
controls remained invisible even when later records had a value in them.

Evi

> I think you need to change the expression to check for Null values (which are
> not the same as zero length string values ("").
[quoted text clipped - 57 lines]
> >
> > Keith.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.