Solution: Changing Forecolor for one Record on Continuous Subform 
Author Message
 Solution: Changing Forecolor for one Record on Continuous Subform

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



Sat, 17 Jun 2000 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Solution: Changing Forecolor for one Record on Continuous Subform

2. Solution: Changing Forecolor for one Record on Continuous Subform

3. Forecolor in one field of one record in a continuous form

4. Changing forecolor in selected subform records

5. Change forecolor on just one record

6. Change one unbound field on a continuous form view subform and they all change

7. Change .Forecolor on the fly on Continuous Form???

8. How can I affect only one record/row in a Continuous SubForm

9. Change backgroud color for record listed in subform in continuous mode

10. Continuous Subforms and changing single record


 
Powered by phpBB® Forum Software © phpBB Group