Colouring Records in a tabular form

  • Thread starter Thread starter james
  • Start date Start date
J

james

Hi I have a form which shows the results of a search
form... Basically what I need to do is when the search is
complete and the results are displayed in the form I would
like one record to be a light blue and the next one down
to be yellow so its easier for the user to look for the
result that they want...

How can I achieve this?

Many Thanks

James
 
You could try to use conditional formatting for this, if you have Access
2002 or newer.

Pavel
 
Yea, you could (programmatically?) assign a format condition to all the
controls you want to highlight using an expression like this:

"TheRowNum(frm) Mod 2 = 0"

Private Function TheRowNum(frm As Access.Form) As Integer
'However - I find it only works for DAO!
'Well... seems to work in ADO if the data is unsorted, for then
..AbsolutePosition is correct
'but, event still, there are multi-user considerations!

On Error GoTo ErrThis
Dim rs As ADODB.Recordset
Set rs = frm.RecordsetClone
With rs
.Bookmark = frm.Bookmark
TheRowNum = .AbsolutePosition + 1
'Debug.Print frm.Bookmark & .AbsolutePosition
End With

ExitThis:
Exit Function

ErrThis:
Select Case Err.number
Case 3021 'No current record
TheRowNum = 0
Case Else
Debug.Print "unhandled error in TheRowNum: " & Err.description &
Err.number
End Select
End Function
 
Hi

I am no where near a big coder as I can just do the
basics... So please could you assist a little further
where by telling me where I need to put the code... WHat
it does...

Also will it change the records as there displayed from a
light blue on the first record and then to a yellow on the
second record then back to light blue then yellow and so
on and so forth??

Many Thanks

James
 
I was in fact referring to the built in conditional formatting. I think
it is only available in form view but requires no coding. Just go to
Format-Cond. formatting and set the criteria.

Pavel
 
There is sample code here:
http://www.lebans.com/conditionalformatting.htm
A2KConditionalFormatting.zip is a sample MDB demonstrating how to
programmatically setup Conditional Formatting to simulate:

1) Highlighting of the Current Row for a Form in Continuous or Datasheet
View

2) Highlighting of Alternate Rows for a Form in Continuous or Datasheet
View

Version 2.7

Added sample demonstrating how to achieve a background
Hover/Highlighting of rows for a form in Continuous view.

Version 2.3

Added sample demonstrating how to achieve pseudo enable/disable of an
unbound control on a form in Continuous View.

Version 1.9

Added sample form to show how to apply conditional formatting to based
on a Boolean(Yes/No) field.

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 
Thanks Stephen!

Pavel

Stephen said:
There is sample code here:
http://www.lebans.com/conditionalformatting.htm
A2KConditionalFormatting.zip is a sample MDB demonstrating how to
programmatically setup Conditional Formatting to simulate:

1) Highlighting of the Current Row for a Form in Continuous or Datasheet
View

2) Highlighting of Alternate Rows for a Form in Continuous or Datasheet
View

Version 2.7

Added sample demonstrating how to achieve a background
Hover/Highlighting of rows for a form in Continuous view.

Version 2.3

Added sample demonstrating how to achieve pseudo enable/disable of an
unbound control on a form in Continuous View.

Version 1.9

Added sample form to show how to apply conditional formatting to based
on a Boolean(Yes/No) field.

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 
Ok I have a better understanding of the Conditional
formatting now.. but I am still unaware of how to get the
records as there displayed as odd or even... I would need
teh expression to say when record = odd be light blue
when record = even be yellow....

How do I do this?? What expression would I need?

Many Thanks

James
 
Back
Top