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.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.