Results 1 to 5 of 5
  1. #1
    HMC62015 is offline Novice
    Windows 10 Access 2016
    Join Date
    Feb 2022
    Posts
    2

    ACCESS2016 report .visible

    Hi - thanks for the read!
    I am looking for some advice on an access report that I need to hide fields and labels based on the underlying record.
    The recordsource is a select query with Left Joins that may have a blank/null record (anyway).
    I have marked .visible as either true or false on report open, then in detail_format, tried to write If Statements to turn the .visible on or off.


    The labels I've turned off for null text box records all worked , but is the .visible for the text boxes false or are they hidden because it is null?
    I have other lines of code (in bold) that do not hide two other labels and a checkbox....

    Can anyone give a suggestion on what I would fix in this ?



    Code:
    Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)    
       If Not IsEmpty([RoHSCompliant]) Then 'Yes/No
        Me.Label111.Visible = True 'Label - always visible
        Me.RoHSCompliant.Visible = True 'Yes/no - always visible
        End If
        If IsNull([PartNote]) Then 'Text Box - recordsource(qry)can be null - is it hidden, or null on print preview?
        Me.Label120.Visible = False 'Label - WORKS!
        Me.PartNote.Visible = False ' Text Box - recordsource(qry)can be null - is it hidden, or null on print preview?
        End If
        If IsNull([OrderDeliveryNote]) Then 'Long Text
        Me.Label119.Visible = False 'label - WORKS!
        Me.OrderDeliveryNote.Visible = False 'Text Box - recordsource(qry)can be null - is it hidden, or null on print preview?
        End If
        If Not IsNull([MfgSites.MSID]) Then 'Text Box - AutoNumber - recordsource(qry) can be null
        Me.Label112.Visible = True 'label - WON'T HIDE
        Me.MFGSite.Visible = True 'Text Box - recordsource(qry)can be null - is it hidden, or null on print preview?
        Me.PAddress1.Visible = True 'Text Box - recordsource(qry)can be null - is it hidden, or null on print preview?
        Me.PAddress2.Visible = True 'Text Box - recordsource(qry)can be null - is it hidden, or null on print preview?
        Me.PCity.Visible = True 'Text Box - recordsource(qry)can be null - is it hidden, or null on print preview?
        Me.PState.Visible = True 'Text Box - recordsource(qry)can be null - is it hidden, or null on print preview?
        Me.PZIP.Visible = True 'Text Box - recordsource(qry)can be null - is it hidden, or null on print preview?
        Me.Pcountry.Visible = True 'Text Box - recordsource(qry)can be null - is it hidden, or null on print preview?
        End If
        If IsNull([CustNote]) Then 'Text Box - recordsource(qry)can be null - is it hidden, or null on print preview?
        Me.Label91.Visible = False 'label - WORKS!
        Me.CustNote.Visible = False 'Text Box - recordsource(qry)can be null - is it hidden, or null on print preview?
        End If
        
        
    End Sub
    
    
    Private Sub Report_Open(Cancel As Integer)
        Me.Label112.Visible = False 'Label
        Me.Label111.Visible = False 'label
        Me.RoHSCompliant.Visible = False 'Yes/No
        Me.Label120.Visible = True 'label
        Me.PartNote.Visible = True 'Short Text
        Me.Label119.Visible = True 'Label
        Me.OrderDeliveryNote.Visible = True 'Long Text
        Me.MFGSite.Visible = False 'Short Text
        Me.PAddress1.Visible = False 'Short Text
        Me.PAddress2.Visible = False 'Short Text
        Me.PCity.Visible = False 'Short Text
        Me.PState.Visible = False 'Short Text
        Me.PZIP.Visible = False 'Short Text
        Me.Pcountry.Visible = False 'Short Text
        Me.Label91.Visible = True 'label
        Me.CustNote.Visible = True 'long Text
    
    
    End Sub

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    I'm not sure I'm understanding, but you can test by setting the Border Style property of a textbox to Solid.

    Presuming your report can return multiple records, you need an Else clause

    Code:
    If Whatever Then
      Me.ControlName.Visible = False
    Else
      Me.ControlName.Visible = True
    End If
    Someone is sure to chime in with Boolean logic which would be a single line:

    Me.ControlName.Visible = Not Whatever

    but is confusing to some developers.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    HMC62015 is offline Novice
    Windows 10 Access 2016
    Join Date
    Feb 2022
    Posts
    2
    Quote Originally Posted by pbaldy View Post
    I'm not sure I'm understanding, but you can test by setting the Border Style property of a textbox to Solid.

    Presuming your report can return multiple records, you need an Else clause

    Code:
    If Whatever Then
      Me.ControlName.Visible = False
    Else
      Me.ControlName.Visible = True
    End If
    Someone is sure to chime in with Boolean logic which would be a single line:

    Me.ControlName.Visible = Not Whatever

    but is confusing to some developers.
    Great news is - I was able to do the simple part and All of the labels are hiding for null text boxes.

    For my checkbox, The VBA debugger is looking for 0, but my records aren't reading that way.
    When I view the back end table the selections to filter the field are 'Yes' or 'No.'
    Yes checkbox is the minority of these records: 1,196 records has 36 Yes.
    When I view the record source (select query ), that is already joined to a certain group of records - and the result is empty - the selection is 'Is Not Selected'

    I am not savvy on the boolean logic , I am sure I wouldn't be able to write it!



    Code:
    Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)    
        If IsEmpty([RoHSCompliant]) Then
        Me.Label111.Visible = False
        Me.RoHSCompliant.Visible = False
        Else
        Me.Label111.Visible = True
        Me.RoHSCompliant.Visible = True
        End If


    Would I change the table, and the resulting query, to show me -1 or 0, instead of the empty checkbox?
    Trying both IsEmpty and Not IsEmpty had no change.
    Is there syntax for 'Is not Selected' in VBA ?

  4. #4
    Gicu's Avatar
    Gicu is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,115
    Could you please try this:
    Code:
    'simplified version
    Me.Label111.Visible = Me.[RoHSCompliant]
    Me.RoHSCompliant.Visible = Me.[RoHSCompliant]
    @Paul: guilty as charged, sorry, didn't mean any disrespect, I just did not notice that in your first post. I agree with you and I usually don't use it like that, but just wanted to point out that with true boolean Yes\No field defined in the table you don't need the extra functions (IsNull(), IsEmpty(), etc.) as it will either be True or False (unlike the SQL server version which also allows for Nulls).
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Open selected record - access2016
    By akika in forum Forms
    Replies: 2
    Last Post: 09-19-2018, 11:31 AM
  2. Access2016: Linking SQL Server View
    By ArviLaanemets in forum SQL Server
    Replies: 1
    Last Post: 01-25-2018, 03:41 AM
  3. Replies: 3
    Last Post: 01-23-2018, 03:21 AM
  4. Replies: 17
    Last Post: 08-03-2017, 06:08 PM
  5. Replies: 2
    Last Post: 01-06-2011, 04:38 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums