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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Equivalent for "Previous"

Status
Not open for further replies.

quinn

MIS
Jun 8, 1999
1
US
I want to compare the contents of a field to the contents in the immediately previous record in a report. SQL I use for instance "If Previous". What do I use in Access? Thank you.
 
I'll admit I don't know the SQL way to do this, and if there is an SQL way, it will be better than what I'm suggesting. <br>
<br>
In the general declaration of the report define 2 variables:<br>
<br>
Dim m_prev$<br>
Dim m_this$<br>
<br>
In the format of the detail section:<br>
<br>
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)<br>
m_prev$ = m_this$<br>
m_this$ = Me.afield 'Change this to the field you are using<br>
End Sub<br>
<br>
In the general declaration of the report goes this function<br>
Private Function get_prev$()<br>
get_prev$ = m_prev$<br>
End Function<br>
<br>
To test this I made a unbound field in the detail section and set the controlsource to =get_prev(). The results were as expected, the unbound control lagged the field by one.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top