John,
This is a workaround to the continuos form problem that has worked well for
me, it takes a bit of setup, but it works well once you get it going.
Assume your continuous form is based on a table that includes the fields
[PaidFlag] (yes/no field) and [Amount] (the value you want to change the
forecolor of)
On your form/subform place the following controls:
ctlPaid
ControlSource = [PaidFlag] (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
ctlAmountRed
ControlSource: =IIf([ctlPaid]=False,[ctlAmountEdit],Null)
Enabled: Yes
Locked: Yes
*** Now do Format -> Send to Back
ctAmountBlack
ControlSource: =IIf([ctlPaid]=True,[ctlAmountEdit],Null)
Enabled: No
Locked: Yes
*** Now do Format -> Send to Back
ctlAmountEdit
ControlSource: [Amount]
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 ctlAmountRed_GotFocus()
Dim lngBlack As Long, lngRed As Long
lngRed = RGB(255, 0, 0)
lngBlack = RGB(0, 0, 0)
If Me!ctlPaid = True Then
Me!ctlAmountEdit.ForeColor = lngRed
Else
Me!ctlAmountEdit.ForeColor = lngBlack
End If
Me!ctlAmountEdit.SetFocus
Thats it, your [Account] should now be red if Paid is true, and black if
Paid is false.
How it works....
ctlAmountRed and ctlAmountBlack manipulate the format property, if true,
ctlAmountRed = [Amount], else it is null and displays nothing.
ctlAmountBlack 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 ctlPaid is true then ctlAmountRed is true, which means it equals the
value in [Amount] this overlaps ctlAmountBlack which is null, and
ctlAmountEdit which is black, but hidden behind ctlAmountRed. When you click
on ctlAmountRed, the code for gotfocus executes. This code checks the value
of ctlPaid and sets the ctlAmountEdit 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.
Give it a try and let me know what you think of this workaround
James H. Brooks
Brooks Consulting
Quote:
>Yip that what exactly what I was trying to do...pity
>> You don't actually say what isn't working, but I'm guessing
>that you are
>> trying to set the forecolor property of a control on a
>continuous form, so
>> that it shows as a different colour depending on the state of
>PaidFlag.
>> If this is what you are trying to do then, it can't be done.
>> The properties of a control are the same for all records, you
>can't have a
>> control with different properties on different records, unless
>you change
>> the property as you move from record to record.
><snip>
> >--
>> ><remove the"x" to reply>
>> >John
>> >Wellington, NZ