highlighting the current record

DNewman

Registered User.
Local time
Today, 08:25
Joined
Oct 12, 2012
Messages
60
I have a subform in which I want to highlight the current record.
I do this by having a hidden field CurrentID into which I copy the record ID when the record gets focus. I then use conditional formatting to light up the record on condition RecordID=CurrentID (for all the visible fields). Works like a treat EXCEPT... I have used the main forms KeyDown sub to use <down arrow> to move into the subform and, would you believe it, only the field that takes the focus gets lit up, not the whole record. As soon as I start moving around the subform - no problem, whole records light up. I am new to this game of threading so sorry if I am totally incoherent.
 
I found this method useful and I tried this with a form and subform and it works fine. Also, I used key down event to set focus in subform and it works fine. I can't actually replicate the issue.

Have you solved the matter?
 
Glad it was helpful.
I am in Access 2010
my code is:
Main Form: the relevant bit of code is

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)

Select Case KeyCode
Case vbKeyDown
If Me.ActiveControl.Name = "txtDate" Then
Me.subEntry.SetFocus
Me.subEntry.Controls("txtNumber").SetFocus
Me.subEntry.Controls("CurrentID") = Me.subEntry.Controls("SpeciesID")
Me.Refresh 'otherwise no fields were effected
KeyCode = 0
End If

End Select

End Sub

This only "lights up" the field txtNumber which takes the focus.
I have obviously got something wrong that you got right!
Help would be gratefully received!
 
Right now I can't try your code, but I post a sample for you to see.
 

Attachments

Great! I have now solved my problem - seeing your example triggered me in the right direction - I had for some silly reason set my CurrentID field to 0 on Load so the condition was initially false. You also saved me code by using the key_down for the textbox rather than the form (Duh!) !
 

Users who are viewing this thread

Back
Top Bottom