I am creating a database to log maintenance on our inventory of items. Each time maintenance is completed or the status of the item changes, a new record is created to develop a history of maintenance for each item. I have created a report showing a log for each item and I have a "status" field showing whether the item is in stock, issued out, damaged or disposed.
On my report I have created a label in red in the header saying "disposed." I am trying to use the code builder to make the disposed label appear only when the most recent record has a disposed status. While testing my code, I have 2 records showing up in the report. both in the Query and in the report, they are sorted so the most recent record at the top of the list. When I run my code, the label appears only when the second(or older) record has a the correct status. I thought maybe it would only appear if every record in the report had the same status based on my code but when the first row shows disposed and the second does not, the label does not appear. When the second row shows disposed but the first does not, the label does appear.
Here is the simple code I've built into the report onload event:
Private Sub Report_Load()
If Me.Status = "6 - disposed" Then
Me.disposedlabel.Visible = True
Else
Me.disposedlabel.Visible = False
End If
End Sub
I can't figure out how to get the report to look at the most recent record in the report. I know the answer has got to be simple but I've searched for a couple of days through google and haven't come across an answer that fits my question.