Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Expression using previous record in condition 1

Status
Not open for further replies.

jennwood

Technical User
Oct 24, 2002
2
US
I have a report which must be sorted by the job number. Sometimes the job name is the same for a series of numbers. It is not possible to sort by job name in some manner because the name may appear in two separate sequences that I do not want together. What I am looking for is to somehow mark the separation between groups of the same job name for readability. I am hoping that I can enter a separate text box at the top of the detail using an expression as the control source in order to do this. If this is possible, I don't know how to reference the previous record. Something along the lines of =IIf([Job Name]<>[Job Name]-1,&quot;*********&quot;,&quot;&quot;).

For clarification:
Records are something like:
Job # Job Name
100 NAME-A
101 NAME-B
102 NAME-B
103 NAME-B
104 NAME-C
105 NAME-C

The report should look like:
Job # Job Name
100 NAME-A
******************
101 NAME-B
102 NAME-B
103 NAME-B
******************
104 NAME-C
105 NAME-C

Any suggestions?
 
This may do it for you. It seems to work in my test Report. I put the line, Line22, at the top of the Section above the textboxes. Then I added a new textbox, Text23. I set the Control Source of this textbox to =1, I set the visible property to NO, and I set the Running Sum to OverAll. The only reason I needed this textbox at all was to test for the first line. Then I put this code in the Format property for the Detail section, where my information was.
Code:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Static strHolder As String
Static strName As String
strHolder = Me.Job_Name
If strHolder = strName Or Me.Text23 = 1 Then
  Me.Line22.Visible = False
  strName = strHolder
Else
  Me.Line22.Visible = True
  strName = strHolder
End If

End Sub

You will have to change the names to ones that are appropriate for you.

Paul
 
I did a couple of things wrong in the beginning, but it now works!!! THANK YOU!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top