详细带格式事件执行一次以上,每行 [英] Format event of Detail band executes more than once per row
问题描述
这是我的code交替颜色行中的数据发生变化时。 因为我是研究一种反常现象,其中一条线没有改变,它应该我发现,访问被看的每一行不止一次。
为什么在看数据超过一次?
私人小组Detail_Format(取消作为整数,FormatCount作为整数)
昏暗的测试作为字符串
如果ISNULL(Text158.Value)然后
pubstrFirstDetaildata =
其他
pubstrFirstDetaildata = Text158.Value
结束如果
如果pubstrFirstDetaildata<> pubstrLastDetaildata然后
backcolorCount = backcolorCount + 1
如果backcolorCountmod2 = 1,则
Me.Detail.BackColor =缬氨酸(与& H与&EDEDED)
Me.Box160.BackColor =缬氨酸(与& H与&EDEDED)
其他
Me.Detail.BackColor = vbWhite
Me.Box160.BackColor = vbWhite
结束如果
结束如果
如果ISNULL(Text158.Value)然后
pubstrLastDetaildata =
其他
pubstrLastDetaildata = Text158.Value
结束如果
Text177 = backcolorCount
结束小组
为什么在看数据超过一次?
所建议的参数列表中 FormatCount
参数,在格式
的详细信息
带可以发射一次以上的记录源给定行视作为报表被渲染会发生什么。例如,如果报告中有一个或多个组定义,这些群体已经保持在一起的一个再启用一种可能性可能是
- 的
格式
事件触发第一次给定的行, - 的报告继续渲染,后续行可能会导致本集团波及到下一个页面,所以
- 的报告开始新的一页,备份之类的开始
格式
再次那些行。
如果你想确保code。在格式
事件仅每行执行一次,那么你可以把它放在一个如果FormatCount = 1,则
块。
This my code to alternately color rows when the data changes. As i was researching an anomaly where a line did not change where it should i found that Access is looking at the each line more than once.
Why is it looking at the data more than once?
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dim test As String
If IsNull(Text158.Value) Then
pubstrFirstDetaildata = ""
Else
pubstrFirstDetaildata = Text158.Value
End If
If pubstrFirstDetaildata <> pubstrLastDetaildata Then
backcolorCount = backcolorCount + 1
If backcolorCount Mod 2 = 1 Then
Me.Detail.BackColor = Val("&H" & "EDEDED")
Me.Box160.BackColor = Val("&H" & "EDEDED")
Else
Me.Detail.BackColor = vbWhite
Me.Box160.BackColor = vbWhite
End If
End If
If IsNull(Text158.Value) Then
pubstrLastDetaildata = ""
Else
pubstrLastDetaildata = Text158.Value
End If
Text177 = backcolorCount
End Sub
Why is it looking at the data more than once?
As suggested by the FormatCount
parameter in the argument list, the Format
event of the Detail
band can fire more than once for a given row in the Record Source depending on what happens as the report is being rendered. For example, if the report has one or more Groups defined and one of those groups has "Keep Together" enabled then one possibility might be that
- the
Format
event fires the first time for a given row, - as the report continues to render, subsequent rows can cause the group to spill over onto the next page, so
- the report starts a new page and "backs up" to the beginning of the group to
Format
those rows again.
If you want to ensure that the code in the Format
event is only executed once per row then you can put it inside an If FormatCount = 1 Then
block.
这篇关于详细带格式事件执行一次以上,每行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!