473,405 Members | 2,354 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Changing Formatting of All Controls in Current Record

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

Nov 12 '05 #1
4 4102
DBQueen wrote:
I have a subform which is in Continuous Forms view.

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?)


It is implicit. You can refer to the current record's values by
addressing the fields (me!yourfield).

You cannot address the *controls* on the form for the current record
only, because the controls are defined only once.
--
Bas Cost Budde
http://www.heuveltop.nl/BasCB

Nov 12 '05 #2
My first thought was to just use Me!....However, ALL of the records on the
form change to a bold font, not just the current record which has the focus.
That is because ME refers to the current form, not an individual record on
the form. Remember, I'm using Continuous Forms view. Therefore, I think
using Recordsets and/or Bookmarks is necessary, but I'm not sure how to get
it to work correctly.

Andi

"Bas Cost Budde" <ba*@heuveltop.org> wrote in message
news:bv**********@news2.solcon.nl...
DBQueen wrote:
I have a subform which is in Continuous Forms view.

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?)


It is implicit. You can refer to the current record's values by
addressing the fields (me!yourfield).

You cannot address the *controls* on the form for the current record
only, because the controls are defined only once.
--
Bas Cost Budde
http://www.heuveltop.nl/BasCB

Nov 12 '05 #3
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


Nov 12 '05 #4
Thanks, Steve. I'll give it a try!
Andi Plotsky
"Steve Jorgensen" <no****@nospam.nospam> wrote in message
news:tg********************************@4ax.com...
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 recordusing 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 tothe 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

Nov 12 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Prakash Wadhwani | last post by:
I have 3 fields : First_Name, Last_Name & Policy_Number I'm using a continuous form. If I invoke conditional formatting on First_Name & set a condition of "Prakash" (change the foreground to...
2
by: aaj | last post by:
Hi all I have a small but rather annoying problem with continuos forms, and am wondering if anyone can suggest a method of getting over it. The front end is Access 2002 with the BE being SQL...
1
by: Tony | last post by:
I have a form in access that has 5 fields for a certain record: 1)Date mailed, 2)Date received, 3)Date completed 4)Foreign Content amount and 5)record number. If the foreign content (FC)is >15% of...
1
by: WindAndWaves | last post by:
Hey Folks I seem to be asking millions of questions. Truth is, I just discovered this awesome research and having been typing by myself for years the questions are all coming out. Here is...
2
by: Paul Mendez | last post by:
I have a form that consists of 150 records and is still growing. there are times when I want to print a certain record of the form, say record 12. I go to file --> print and choose the page number...
8
by: Zlatko Matić | last post by:
There is a form (single form) and a combobox. I want that current record of the form is adjusted according to selected value in the combobox. Cuurrent record should be the same as the value in the...
0
by: Cato Lommerud | last post by:
I have a datagrid control that shows the result from an Acces View and I want to change the current record for other bound controls when the user clicks in the different rows in the datagrid. Since...
1
by: David | last post by:
Hi, I have a continuous form. For each record I have a field 'HeldDate' (Text Field from a table) Against each record I have a button which sets the visibility of this text box to 'True' and...
1
by: planetthoughtful | last post by:
Hi All, I have a mainform with a subform in which I show some task summary data. On the mainform I have a number of unbound controls that reflect values relevant to each task in the subform....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.