The only way to format data in some rows different than others is to use
Conditional Formatting, but there's no built-in way to identify what is the
currently selected row to format. So, here's the trick...
You need 2 invisible controls on the form, one bound to the record's primary
key column, and one unbound that will hold a copy of the key for the current
row (e.g. txtFooID and txtDooIDCur). Next, add a Current event handler to
your form that copies the key value to the unbound control (e.g.
Me!txtFooIDCur = me!txtFooID). Finally, set the conditional formatting for
each control on the form to be bold when Me!txtFooIDCur = me!txtFooID.
Note that this is a bit of a maintenance hassle since, if you decide later
that you want the current row to be, say, a different color rather than bold,
you have to edit the custom formatting for each control individually.
Technically, you can highlight all the controls, and change the custom
formatting for all at once, but if any control has something different about
its formatting, that will fail when you try to apply the change - this problem
occurs more often than not.
So, I recommend writing a procedure that takes a control as its argument and
adds a set of Conditional Formatting attributes appropriately. In the form's
Open event handler, call the function once for each control in question, so
conditional formatting is set up. Now, to change the conditional formatting,
you just change 1 or 2 lines in the procedure, and to change which controls it
applies to, you just edit the code block in Form_Open with the sequence of
calls to the procedure.
See the Help files for more on how to set Conditional Formatting from code.
On Tue, 3 Feb 2004 01:34:52 -0500, "DBQueen" <ir******@bellsouth.net> wrote:
I have a subform which is in Continuous Forms view.
I have added a button to the bottom of the page to move to the next record
using the button wizard (result: DoCmd.GoToRecord , , acNext).
I want all of the controls in whatever is the CURRENT record to have it's
data bolded on the screen. (Question #1: Is there a SIMPLE way to refer to
the Current Record?)
I've been trying to use a Bookmark to specify the current record, but it
doesn't seem to work. I keep either getting error msgs or ALL records'
controls are bolded.
Form_Current:
Dim ocontrol As control
Dim rst As DAO.Recordset
Dim varBookmark As Variant
SampleID.FontWeight = 400 '400=Normal fontweight
SubjName.FontWeight = 400
TimeOfSample.FontWeight = 400
Set rst = Me.RecordsetClone
varBookmark = Me.Bookmark
For Each ocontrol In varBookmark 'this gives me an "Object Required error"
SampleID.FontWeight = 900 '900 =bold fontweight
SubjName.FontWeight = 900
TimeOfSample.FontWeight = 900
Next ocontrol
Any help would be greatly appreciated.
Thanks!
Andi