Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

formatting detail section of form to alterntive colours

Status
Not open for further replies.

maudedo

MIS
Jul 10, 2003
41
GB
Hello
Would like to know if it is possible to have a detail of a form (which is set as continuous form not datasheet) in alternative colours..

ie record 1 = colour 1
record 2 = colour 2
record 3 = colour 1
record 4 = colour 2
record 5 = colour 1 etc.?

Many thanks in anticipation..
 
Create a textbox in the detail section and set the running sum to "Over all" and the control source to =1 and set visible to no.

then place the following code in the events procedure of the detail section. Substitute the names of your controls for Control1, Control2 etc. Each line will alternate backcolor from white to gray. The Mod function returns the remainder of the record number divided by 2. If the remainder is 0 then show gray backcolor.

Private Sub Detail1_Print(Cancel As Integer, PrintCount As Integer)
If Me.RecCt Mod 2 = 0 Then
Me.Control1.BackColor = 12632256 'gray
Me.Control2.BackColor = 12632256
Me.Control3.BackColor = 12632256

Else
Me.Control1.BackColor = 16777215 'white
Me.Control2.BackColor = 16777215
Me.Control3.BackColor = 16777215

End If
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top