Printing Selective Fields in Detail or Footer Section of Report

G

Guest

Hi..I have noticed in a previous post that the command
Me.[myreportfield].Visible=True (or False) used in the OnFormat property can
hide or display the field based on the condition.

I got a couple of questions.
1. Does it matter whether it is used in the Detail Section of the report or
the Footer Section?
2. Can it be used to hide lines?
3. When Printing more than one record, it only checks the condition on the
first record. The next record will keep the condition based on the first
record even it is different. Here's my code...
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If Me.New = "New" Then
Me.EExBldg.Visible = False
Me.EExFlr.Visible = False
Me.EExRoomNo.Visible = False
Me.EExID.Visible = False
Me.EExMonAlT.Visible = False
Me.MonitorAlarmNeed.Visible = False
End If

End Sub

4. Why the following code does not do any effect?
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)

If Me.FPLF = "Not Defined" Then
ElseIf Me.StgFPLF = "Not Defined" Then
ElseIf Me.StgLF = "Not Defined" Then
Me.Line1.Visible = False
Me.Label1.Visible = False
Me.Label2.Visible = False
Me.Label3.Visible = False
End If

End Sub

Your help will be appreciated.
 
M

Marshall Barton

Martin said:
Hi..I have noticed in a previous post that the command
Me.[myreportfield].Visible=True (or False) used in the OnFormat property can
hide or display the field based on the condition.

I got a couple of questions.
1. Does it matter whether it is used in the Detail Section of the report or
the Footer Section?
2. Can it be used to hide lines?
3. When Printing more than one record, it only checks the condition on the
first record. The next record will keep the condition based on the first
record even it is different. Here's my code...
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If Me.New = "New" Then
Me.EExBldg.Visible = False
Me.EExFlr.Visible = False
Me.EExRoomNo.Visible = False
Me.EExID.Visible = False
Me.EExMonAlT.Visible = False
Me.MonitorAlarmNeed.Visible = False
End If

End Sub

4. Why the following code does not do any effect?
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)

If Me.FPLF = "Not Defined" Then
ElseIf Me.StgFPLF = "Not Defined" Then
ElseIf Me.StgLF = "Not Defined" Then
Me.Line1.Visible = False
Me.Label1.Visible = False
Me.Label2.Visible = False
Me.Label3.Visible = False
End If

End Sub


Answers:
1. It should be in the same section as the controls you are
manipulating.

2. Yes

3. Your problem here is because you never set the controls
Visible to True. You need to cover both cases:

Me.EExBldg.Visible = (Me.New = "New")
. . .

4. The ElseIf blocks are mutually exclusive. Like 3. above,
you need to deal with all cases:

Dim bolSHow As Boolean
bolShow = Not (Me.FPLF = "Not Defined" _
OR Me.StgFPLF = "Not Defined" _
OR Me.StgLF = "Not Defined")
Me.Line1.Visible = bolShow
. . .
 
G

Guest

Thanks. Your approach was more succinct.

Marshall Barton said:
Martin said:
Hi..I have noticed in a previous post that the command
Me.[myreportfield].Visible=True (or False) used in the OnFormat property can
hide or display the field based on the condition.

I got a couple of questions.
1. Does it matter whether it is used in the Detail Section of the report or
the Footer Section?
2. Can it be used to hide lines?
3. When Printing more than one record, it only checks the condition on the
first record. The next record will keep the condition based on the first
record even it is different. Here's my code...
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If Me.New = "New" Then
Me.EExBldg.Visible = False
Me.EExFlr.Visible = False
Me.EExRoomNo.Visible = False
Me.EExID.Visible = False
Me.EExMonAlT.Visible = False
Me.MonitorAlarmNeed.Visible = False
End If

End Sub

4. Why the following code does not do any effect?
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)

If Me.FPLF = "Not Defined" Then
ElseIf Me.StgFPLF = "Not Defined" Then
ElseIf Me.StgLF = "Not Defined" Then
Me.Line1.Visible = False
Me.Label1.Visible = False
Me.Label2.Visible = False
Me.Label3.Visible = False
End If

End Sub


Answers:
1. It should be in the same section as the controls you are
manipulating.

2. Yes

3. Your problem here is because you never set the controls
Visible to True. You need to cover both cases:

Me.EExBldg.Visible = (Me.New = "New")
. . .

4. The ElseIf blocks are mutually exclusive. Like 3. above,
you need to deal with all cases:

Dim bolSHow As Boolean
bolShow = Not (Me.FPLF = "Not Defined" _
OR Me.StgFPLF = "Not Defined" _
OR Me.StgLF = "Not Defined")
Me.Line1.Visible = bolShow
. . .
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top