View Full Version : Generating a Sequence Number


BPlenge
05-14-2007, 08:03 AM
I am using the following code to generate a sequence number. It works, but my issue is that it starts numbering on the second record. IE: record two shows a 1; record three shows a 2, etc. Can some one tell me how to make the first record show a 1, etc?


Dim DtlSRecipIDCurrent, DtlSRecipIDPrevious As Variant
Dim DtlSPayToProvCurrent, DtlSPayToProvPrevious As Variant
Dim RecipSeqNumber As Integer

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)

DtlSPayToProvCurrent = Me.txtDtlSPayToProvID
DtlSRecipIDCurrent = Me.txtSRecipOrigID

If DtlSPayToProvCurrent = DtlSPayToProvPrevious Then
If DtlSRecipIDCurrent <> DtlSRecipIDPrevious Then
RecipSeqNumber = RecipSeqNumber + 1
End If
ElseIf DtlSPayToProvCurrent <> DtlSPayToProvPrevious Then
RecipSeqNumber = 1
End If

Me.txtSRecipSeqNum = RecipSeqNumber
'Me.txtSRecipSeqNum = 3

DtlSPayToProvPrevious = DtlSPayToProvCurrent
DtlSRecipIDPrevious = DtlSRecipIDCurrent


Thanks for you help.

Bill

The_Doc_Man
05-14-2007, 08:24 AM
Put an entry in the Report Header OnFormat routine to initialize that counter to 1.

BPlenge
05-14-2007, 09:22 AM
Doc_Man - Thanks for your reply. I don't want the counter to necessarily reset at every page. Basically, what I'm trying to do is a running sum within a group.

The report has three groups. I tried the regular running sum function on the report, but the report is basing the count on group 2, and I want the count to be based on group 3. Is there a way to control what group the report bases the count on?

Congratulations on being a grand pa.

Rich
05-14-2007, 09:50 AM
Set an unbound textbox control source to =1 , set the running sum property to over group

BPlenge
05-14-2007, 10:33 AM
I have the running sum in group 3. It resets when group 2 changes values. Is there a way to get it to reset when group 1 changes values?

Thanks.