Highlight a selected record

  • Thread starter lmcc via AccessMonster.com
  • Start date
L

lmcc via AccessMonster.com

I am trying to highlight a selected record of a continuous form. Conditional
Formatting is not working because it highlights individual fields. If
Conditional Formatting would highlight the entire row, it would be perfect.

I created a txtBackground text box to size of all my fields, sent it the
back—behind the fields. Use the txtBackground as the control, but when it
has focus it covers the data. Below is the code I used:


Sub HighlightControl(ctl As Control)
On Error Resume Next
ctl.BackColor = 65535
End Sub


Sub UnhighlightControl(ctl As Control)
On Error Resume Next
ctl.BackColor = 16777215
End Sub


Private Sub txtBackground_GotFocus()
HighlightControl Me.txtBackground
End Sub

Private Sub txtBackground_LostFocus()
UnHighlightControl Me.txtBackground
End Sub

Any suggestions is appreciated. Thanks!
 
M

Marshall Barton

lmcc said:
I am trying to highlight a selected record of a continuous form. Conditional
Formatting is not working because it highlights individual fields. If
Conditional Formatting would highlight the entire row, it would be perfect.

I created a txtBackground text box to size of all my fields, sent it the
back—behind the fields. Use the txtBackground as the control, but when it
has focus it covers the data. Below is the code I used:

Sub HighlightControl(ctl As Control)
On Error Resume Next
ctl.BackColor = 65535
End Sub

Sub UnhighlightControl(ctl As Control)
On Error Resume Next
ctl.BackColor = 16777215
End Sub

Private Sub txtBackground_GotFocus()
HighlightControl Me.txtBackground
End Sub

Private Sub txtBackground_LostFocus()
UnHighlightControl Me.txtBackground
End Sub


I don't understand what your code is trying to do. or why
you are setting the focus to txtBackground.

You should use Conditional formatting on the big (size of
the details section) txtBackground text box. You did not
say which record(s?) should be highlighted so I can't say
how to do that. You may(?) also want to set all the other
text boxes' BackStyle to Transparent.

To prevent the big text box from getting the focus, set its
Enabled to No and Locked to Yes.
 
L

lmcc via AccessMonster.com

Thanks Marshall,

I was trying to delete this thread but could not find how to. I was
following Tracking the Focus example in a book, which the examples are for
individual controls--not a whole row like I was trying to do. Anyway,
Conditionally Formatting does what this code does without using VBA.


Marshall said:
I am trying to highlight a selected record of a continuous form. Conditional
Formatting is not working because it highlights individual fields. If
[quoted text clipped - 21 lines]
UnHighlightControl Me.txtBackground
End Sub

I don't understand what your code is trying to do. or why
you are setting the focus to txtBackground.

You should use Conditional formatting on the big (size of
the details section) txtBackground text box. You did not
say which record(s?) should be highlighted so I can't say
how to do that. You may(?) also want to set all the other
text boxes' BackStyle to Transparent.

To prevent the big text box from getting the focus, set its
Enabled to No and Locked to Yes.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top