Results 1 to 8 of 8
  1. #1
    New Lounger
    Join Date
    Oct 2002
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Suppress labels on report for fields with no data (access 2000)

    We have a report that is very basic. In three columns, it just repeats the fields in the source table. So each record takes up at least 7 lines to print, since there are 7 fields. The user is wanting to keep from printing fields that have no data in them. I know that I can set the property for the text box on the report to "Can Shrink" and it will skip over the field itself, but the label prints anyway. Is there an easy way to leave off the label if the text box shrinks?

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Suppress labels on report for fields with no data (access 2000)

    You can write code for the OnFormat event of the detail section of the report. It could look like this:

    Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
    [lblField1].Visible = Not IsNull([txtField1])
    [lblField2].Visible = Not IsNull([txtField2])
    End Sub

    Replace txtField1 by the name of a textbox, and lblField1 by the name of the attached label, etc. You must have a line for each of the text boxes that may contain null values. Don't forget to set the CanShrink property of the detail section to Yes too.

  3. #3
    Star Lounger
    Join Date
    May 2002
    Posts
    53
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Suppress labels on report for fields with no data (access 2000)

    I want to do this same thing on my report, but I have three fields and I want them invisible only if all three are blank...what would the code look like in this case? Would it be an If..statement? Thanks, I'm just learning...

    Sarah

  4. #4
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: Suppress labels on report for fields with no data (access 2000)

    You said:
    <<I want to do this same thing on my report, but I have three fields and I want them invisible only if all three are blank>>

    I presume that you meant the labels to be invisible, in which case you could do the following in the OnFormat event of the Detail section of your report.

    If IsNull(Field1) and IsNull(Field2) and IsNull(Field3) then
    Field1Label.Visible = False
    Field2Label.Visible = False
    Field3Label.Visible = False
    Else
    Field1Label.Visible = True
    Field2Label.Visible = True
    Field3Label.Visible = True
    Endif

    HTH
    Pat <img src=/S/smile.gif border=0 alt=smile width=15 height=15>

  5. #5
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: Suppress labels on report for fields with no data (access 2000)

    In my previous post I mantioned to set the Visible property of the Label to True or False.
    In fact you can set the Control's visible property (not the Label's property) to True or False, this will also set the Label's Visible property to True or False accordingly.
    Sorry for any confusion.
    Pat <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>

  6. #6
    Star Lounger
    Join Date
    May 2002
    Posts
    53
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Suppress labels on report for fields with no data (access 2000)

    Thanks for your help Pat. I'll try it out!

  7. #7
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: Suppress labels on report for fields with no data (access 2000)

    BTW, which island are you from?
    Pat <img src=/S/smile.gif border=0 alt=smile width=15 height=15>

  8. #8
    Star Lounger
    Join Date
    May 2002
    Posts
    53
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Suppress labels on report for fields with no data (access 2000)

    Lived in Key West for a few years...not really sure why I left... <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •