
Changing Text on One record on a Continuous sub form
Tim,
Here is a solution to your problem. By manipulating several controls and
format properties you can pretty slickly get around Access' limitations.
** Note: This will show you how to do it for field [Order_Num], just copy
the technique for field [Roll_Number]
On your form/subform place the following controls:
ctlHold
ControlSource = [hold] (which should be true/false)
create the next three controls in the following order, it will make things
easier:
for each control, set the background color to transparent
ctlOrderRed
ControlSource: =IIf([ctlHold]=False,[ctlOrderEdit],Null)
Enabled: Yes
Locked: Yes
*** Now do Format -> Send to Back
ctlOrderBlack
ControlSource: =IIf([ctlHold]=True,[ctlOrderedit],Null)
Enabled: No
Locked: Yes
*** Now do Format -> Send to Back
ctlOrderEdit
ControlSource: [Order_Num]
Enabled: Yes
Locked: No
*** Now do Format -> Send to Back
Line up the three controls so that they are right over each other.
Next add the following code to ctlOrderRed_GotFocus()
Dim lngBlack As Long, lngRed As Long
lngRed = RGB(255, 0, 0)
lngBlack = RGB(0, 0, 0)
If Me!ctlHold = True Then
Me!ctlOrderEdit.ForeColor = lngRed
Else
Me!ctlOrderEdit.ForeColor = lngBlack
End If
Me!ctlOrderEdit.SetFocus
Thats it, your order_num should now be red if hold is true, and black if
hold is false.
How it works....
ctlOrderRed and ctlOrderBlack manipulate the format property, if true,
ctlOrderRed = [Order_Num], else it is null and displays nothing.
ctlOrderBlack is just the opposite. Since the format property can change the
format for each record in a continuous form, we manipulate it to change the
forecolor. By setting the controls to transparent, we overlap their values.
So if ctlHold is true then ctlOrderRed is true, which means it equals the
value in [Order_Num]this overlaps ctlOrderBlack which is null, and
ctlOrderEdit which is black, but hidden behind ctlOrderRed. When you click
on ctlOrderRed, the code for gotfocus executes. This code checks the value
of hold and sets the ctlOrderEdit forecolor to red or black. This actually
changes for all controls on the form, but since this control only shows
while it is being editted (otherwise its in back of the other controls), it
doesn't matter. This procedure can easily be dup,icated for the
[Roll_Number] control as well.
Give it a try and let me know what you think of this workaround.
James H Brooks
Brooks Consulting
Quote:
>Can anyone tell me how I could change the forecolor of a text field for
only
>one record on a continuous subform?
>I currently base this decision on a value of a checkbox and need to change
>two field red when it evaluates True. But when I do this, I change this
>record plus all other record since this is on a continuous form.
>Any help would be great.
>Tim Bloomer