Combo Box

  • Thread starter Thread starter Eva
  • Start date Start date
E

Eva

I have a combo box that searches for a record by last name
using the code below. What can be added to the code to
highlight the record with - let's say - a yellow color
when the record is found?
You may need more information - I wasn't sure what.

Thank you

Private Sub Combo41_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[LastName] = '" & Me![Combo41] & "'"
Me.Bookmark = rs.Bookmark
End Sub
 
I don't think "conditional formating" is so advanced in Access that it can do this, but I may be wrong. However, I know that you can very easily change the fore color or background color of a control in VB.

me.Combo41.BackColor = {Enter the color number here

me.Combo41.ForeColor = {Enter the color number here

Hope this helps.
 
-----Original Message-----
I don't think "conditional formating" is so advanced in
Access that it can do this, but I may be wrong. However,
I know that you can very easily change the fore color or
background color of a control in VB.
me.Combo41.BackColor = {Enter the color number here}

me.Combo41.ForeColor = {Enter the color number here}

Hope this helps.

Thank you for your help - Where do I place this code?
 
I would put it into an if statement within your AfterUpdate Sub. I would personally create a loop statement to find the matching record, but that may not be the fastest way to find the first record

Do Until rs.eo
if rs!LastName = me.combo41 the
me.Combo41.BackColor = {Enter the color number here
End i
rs.movenex
loo
 
Back
Top