Results 1 to 11 of 11
  1. #1
    Join Date
    Oct 2004
    Posts
    4

    Unanswered: Hide report label if field value null

    Can someone help. I have a report based on a query that shows a list of grades students get for a list subject, one page per student.
    Some students do not take certain subjects. Therefore I need to hide the label showing field name if the data in that field is null.
    i.e. if Jonnie does not take Math (indicated by no value in that text field) then do not show the label math on his report
    Thanks
    Richard

  2. #2
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    Detail_Format section ... Test if value is null and then if so do: SomeLabel.Visible=False

    Make sure to make the conditional an If Then Else ...
    Back to Access ... ADO is not the way to go for speed ...

  3. #3
    Join Date
    Oct 2004
    Posts
    4

    Re Hide label if field null

    Thanks for this Owen but not using access much can you tell me how to add this. I understand a basic if then else but dont know eher to write it.. do i use expressions builder or code builder and would:
    if textbox isnull then
    label5.visible=true else
    work??
    Any help appreciated

  4. #4
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    Well I'm talking about VBA code ... For your report you just select the report and click on View->Code on the toolbar. Then select the Detail section in the left combobox ...
    Back to Access ... ADO is not the way to go for speed ...

  5. #5
    Join Date
    Oct 2004
    Posts
    4

    re hide label

    ok i dont know VBA but got into the code and tried:

    Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
    If artgrade Is Null Then Label5.Visible = False Else
    End Sub
    it errors on "Object required"

    Where am i going wrong? Apart from using delphi generally in life!

  6. #6
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    Quote Originally Posted by kirkbyr
    ok i dont know VBA but got into the code and tried:

    Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
    If artgrade Is Null Then Label5.Visible = False Else
    End Sub
    it errors on "Object required"

    Where am i going wrong? Apart from using delphi generally in life!
    Poor code ... Try:

    ...
    If artgrade & ""="" Then
    Label5.Visible=False
    else
    Label5.Visible=True
    endif
    ...
    Back to Access ... ADO is not the way to go for speed ...

  7. #7
    Join Date
    Oct 2004
    Posts
    4

    re

    mmm that takes the first record and turns the label off but does not check each record and turn it back on if they have got a grade
    thanks for the reply though

  8. #8
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    Quote Originally Posted by kirkbyr
    mmm that takes the first record and turns the label off but does not check each record and turn it back on if they have got a grade
    thanks for the reply though
    Is this label in the detail section of the report??? If it is, that code does work ...
    Back to Access ... ADO is not the way to go for speed ...

  9. #9
    Join Date
    Apr 2009
    Posts
    2
    Thanks for the code above - it works well. But what does the & ""="" do? Why can't you use something to recognise it simply as a null?

  10. #10
    Join Date
    Apr 2009
    Posts
    2
    Quote Originally Posted by M Owen
    Is this label in the detail section of the report??? If it is, that code does work ...
    Also check that you have included the 'Else If' option. Access doesn't let you skip this second half and display default value automatically. For some reason it needs to be told what to do in all cases after you start changing it for some cases.

  11. #11
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    Quote Originally Posted by Yukiko
    Thanks for the code above - it works well. But what does the & ""="" do? Why can't you use something to recognise it simply as a null?
    My thoughts exactly. I've no idea what ""="" means.

    I would have gone with If IsNull(artgrade) Then...
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

Posting Permissions

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