Access Highlight Current Record -- Nice and easy
Posted on 2013-01-11
I am using Access 2010. I am using a continuous form.
I was doing some research on how to highlight the current record in a continuous form. I found several solutions that were close --- but no cigar!
I found (for me) a perfect solution..... but it needs refining.
I came up with the idea of creating a boolean field in the underlying table... Field name is ................ [IsCurrentRecord].. The idea is that this field will be "True" for a record when the recordset.currentrecord points to that record.
Now, some coding for the form
Private Sub Form_Current()
[IsCurrentRecord] = True
Private Sub Form_BeforeUpdate(Cancel As Integer)
[IsCurrentRecord] = False
Conditional formatting on AnyField ----------- If [IsCurrentRecord] = True <then color background>
This works perfectly for me. It highlights the current record. It even highlights newly created records! It's perfect except for one caveat.
The record becomes dirty (edit mode in case I have the lingo wrong) even though the user really is not wanting to edit the record. Instead, I would like the following behaviour.
A) When I land on this record I wish to set [IsCurrentRecord] to true and then save the record (to get rid of the Edit Flag).
B) When I exit this record, then I want to set [IsCurrentRecord] to false and again save the record. If the focus goes on another record, go back to "A"