Private Sub 主体_Print(Cancel As Integer, PrintCount As Integer)
Select Case Me.文本25
Case 1
'If PrintCount > 1 Then Call ForeColorSet(Me)
If PrintCount < 3 Then Me.NextRecord = False
Case 2
intCount = intCount + 1
'If intCount = 3 Then Call ForeColorSet(Me)
If intCount > 1 Then
If PrintCount < 2 Then Me.NextRecord = False
End If
End Select
End Sub 作者: thzbc 时间: 2007-5-15 23:46
谢谢hi-wzj 老师的帮助;
就是:在明细子报表中第一行输入数据。下面两行全部显示是第一行的记录。在第二行输入数据后。第三行显示的也是第二行的数据作者: sgrshh29 时间: 2007-5-16 00:56
你这是copy来的代码,对于你这种报表的实例不适用。关键在于你的记录有1、2、3条之分,不能用PrintCount来计数。请把下面的代码copy到你的报表中,这段代码没有测试过3条以上的记录,如果3条以上有问题,你可以根据1、2条记录的写法,自己改一下(在case else这段里面)。另外这个函数也不合适你的情况,改动了一下。Option Compare Database
Option Explicit
Dim intCount As IntegerPublic Function ForeColorSet(rpt As Report, Asbl As Boolean)
Dim ctl As Control
For Each ctl In rpt.Section(0).Controls
If TypeOf ctl Is TextBox Then
If Asbl Then
ctl.ForeColor = 16777215
Else
ctl.ForeColor = 0
End If
End If
Next ctl
End FunctionPrivate Sub Report_Open(Cancel As Integer)
intCount = 0
Call ForeColorSet(Me, False)
End SubPrivate Sub 主体_Print(Cancel As Integer, PrintCount As Integer)
Select Case Me.文本25
Case 1
intCount = intCount + 1
If intCount = 1 Then
Me.NextRecord = False
End If
If intCount > 1 Then
Me.NextRecord = False
Call ForeColorSet(Me, True)
End If
If intCount = 3 Then
Me.NextRecord = True
End If
If intCount > 3 Then Call ForeColorSet(Me, False)
Case 2
intCount = intCount + 1
If intCount = 2 Then
Me.NextRecord = False
End If
If intCount > 2 Then
Me.NextRecord = False
Call ForeColorSet(Me, True)
End If
If intCount = 3 Then
Me.NextRecord = True
End If
If intCount > 3 Then Call ForeColorSet(Me, False)
Case Else
intCount = intCount + 1
If intCou作者: thzbc 时间: 2007-5-16 01:43
谢谢sgrshh29 老师帮助。这回好像可以达到效果了。我明天去单位试打一下就知道了。再次谢谢。可以将QQ号告我吗?以后联系。 作者: thzbc 时间: 2007-5-16 06:20
sgrshh29 老师:你好!