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