forms/fields

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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!
 
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.
 

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

Back
Top