"Fore Color"

B

Bill Stanton

In a form with "continuous forms" detail section, how do I
get control as each record is read so that I can conditionally
change the font color.

I tried to set the color in the "Before Update" event of the
control, but there's no option provided to do so. I.e., the
field of interest is named "Type", but there's no option to
change Me.Type.Forecolor, Me.Type.Properties.Forecolor
or anything similar that I could find.

Thanks,
Bill Stanton
 
V

Van T. Dinh

You may be referring to the Field (of the Recordset to which the Form is
bound) which does not have the "ForeColor" Property. Only the Control has
the "ForeColor" Property.

Check and make sure that you are using the Control name and not the Field
name. If they are the same, try rename the Control to something different
and use the Control name. (However, my bet is that they are not the same in
your set-up.)

I am not sure what you are trying to do from your description (" ... as each
record is read ... " doesn't go with " ... in the Before Update event ...")
but I think you should check Access Help on Conditional Formatting which may
be of use to you.
 
B

Bill Stanton

Van,
Sorry about the confusion in the description. The comments regarding
the reading records and the BeforeUpdate came after 4AM frustrations
trying to find the problem and thinking the controls color property might
have to change as the form was being populated.

Anyway, what I'm trying to do is like changing an number's color to red
when it's negative or black if positive. Actually, the RecordSource has
a field, called "Type", that signifies whether another field, entitled
"Amount",
represents receipt in "cash" or "check" and I want to toggle the color to
green when the "type" is cash.

At this point, I've added code to the control's "BeforeUpdate" to examine
the
value of "Type" and change the color property (and yes, you were right
about the field name versus control name question) of the control. That
isn't having any effect, i.e., Me.ControlName.ForeColor = Green,
where Green is Dim'd Long and set appropriately.

I put a MsgBox statement in the event code, but it never "fires", so
obviously I'm still "off base" as to how to dynamically change the
control's color.

I hope this make more sense and that you can tell me what to do.

Thanks,
Bill
 
B

Ben

BeforeUpdate fires when the user changes the data, before
the data is updated to the DB (basically before LostFocus
I think), it's good for validating data and not much else.
You are looking for conditional formatting, which is a
really nice feature of Access and doesn't require code,
its on the Format menu in A2K and up. If you are using
Access 97, I'm really not sure how you could implement
this, never tried. Play with the form's load and activate
events and see if you can get it.
HTH
Ben
-----Original Message-----
Van,
Sorry about the confusion in the description. The comments regarding
the reading records and the BeforeUpdate came after 4AM frustrations
trying to find the problem and thinking the controls color property might
have to change as the form was being populated.

Anyway, what I'm trying to do is like changing an number's color to red
when it's negative or black if positive. Actually, the RecordSource has
a field, called "Type", that signifies whether another field, entitled
"Amount",
represents receipt in "cash" or "check" and I want to toggle the color to
green when the "type" is cash.

At this point, I've added code to the
control's "BeforeUpdate" to examine
 
B

Bill Stanton

BINGO!!!!!!

Obviously my first encounter with "conditional formatting".

Thanks,
Bill
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top