Listbox alternate shading

  • Thread starter Thread starter Bob
  • Start date Start date
B

Bob

Is it possible to have alternate line shading in a list box?

Thanks in advance.........Bob Vance
 
No, but you can create a pop-up form that looks and acts like a listbox then
you can alternate the shading of each row.
 
One way of doing it is to sequentilaay number all the rows on the form then
use conditional formatting to make the even numbered rows one color and the
odd numbered rows another color.

To number rows in the form ----
a.. Put the following in a standard module:
Public Function RowNum(frm As Form) As Variant
On Error GoTo Err_RowNum


With frm.RecordsetClone

.Bookmark = frm.Bookmark

RowNum = .AbsolutePosition + 1

End With


Exit_RowNum:

Exit Function


Err_RowNum:

If Err.Number <> 3021& Then 'Ignore "No bookmark" at new row.

Debug.Print "RowNum() error " & Err.Number & " - " & Err.Description

End If

RowNum = Null

Resume Exit_RowNum

End Function



II. Add an unbound textbox to the form and put the following in its
controlsource:
=RowNum([Form])

Note: You can set the visible property of the textbox to what you prefer.



Even numbered rows: Me!NameOfTextBox Mod 2 = 0

Odd numbered rows: Me!NameOfTextBox Mod 2 <> 0


--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
Over 1175 users have come to me from the newsgroups requesting help
(e-mail address removed)
 

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

Back
Top