forms/fields

P

PeterM

is there a way to use a WITH statement referencing all fields on a form
without having to use their individual names.

I need to set the .forecolor and .backcolor of all fields on all of my forms
each time a form is opened.

Any help would be apprecieated...thank you!
 
D

Dirk Goldgar

PeterM said:
is there a way to use a WITH statement referencing all fields on a
form without having to use their individual names.

I need to set the .forecolor and .backcolor of all fields on all of
my forms each time a form is opened.

Any help would be apprecieated...thank you!

You can loop through the form's Controls collection, like this:

Dim ctl As Access.Control

On Error Resume Next

For Each ctl In Me.Controls
ctl.ForeColor = ...
ctl.BackColor = ...
Next ctl

The "On Error Resume Next" is to ignore the errors for any controls that
don't have these properties.
 
Top