Change frames properties during form Opening

P

Pantelis

I have a form with some sum calculation frames in the
footer.
This form opens in snapshot view.

I want to control the color of the fonts, of the sum frame
(forecolor property),depended on the value of the sum.
I use the following code which work fine if it's attached
with form's events like "On Focus, On Click etc." but does
not work with the form's events "On Open, or On Load" so I
can't have the desired result when I open the form.

It seem's that the values are calculated after these
events.

-------------------------------
Dim varTotal As Variant

Set varTotal = fraTotal 'fraTotal is the summing frame
which I want to control the ForeColor property

If varTotal < 0 Then
Me!fraTotal.ForeColor = 255
Else
Me!fraTotal.ForeColor = 0
End If
 
W

Wayne Morgan

Try the Form's OnCurrent event instead of the Load or Open. Also, if you have Access 2002
(and I believe 2000) there is a built in option for conditional formatting in a control.
You may find this easier to use.
 
M

Marshall Barton

Pantelis said:
I have a form with some sum calculation frames in the
footer.
This form opens in snapshot view.

I want to control the color of the fonts, of the sum frame
(forecolor property),depended on the value of the sum.
I use the following code which work fine if it's attached
with form's events like "On Focus, On Click etc." but does
not work with the form's events "On Open, or On Load" so I
can't have the desired result when I open the form.

It seem's that the values are calculated after these
events.

-------------------------------
Dim varTotal As Variant

Set varTotal = fraTotal 'fraTotal is the summing frame
which I want to control the ForeColor property

If varTotal < 0 Then
Me!fraTotal.ForeColor = 255
Else
Me!fraTotal.ForeColor = 0
End If

For this simple example, you can specify the text box's
Format property to use different colors for positive,
negative, zero and null values, no code needed. For
example:

[Black]0.0;[Red]-0.0;[Blue]"Zero";[Yellow]"Missing"

See Format Property in Help for details on all the custom
formatting options.
 

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