Default properties of a control - Conditional Formatting

D

Dale Fye

I finally figured out how to set the default properties for controls on a
form, and have a template form that has default properties for most of the
controls I regularly use.

However, I've been trying to figure out how to set the default Conditional
formatting for a control. Would like to set textboxs, combos, lists so that
their background color changes when they have the focus.

Anybody know of a way to do this without:
1. creating one of each of these controls on my form, setting their
conditional formatting, and then copying them for each field, or
2. writing a subroutine to look through the controls and do it for me.
 
K

Klatuu

Hi Dale,

Here is a sample function that will do what you want up to a point. The
issue is not all controls have a backcolor property. Check Boxes, for
example do not.

Function FocusBack() As Boolean
Const conNormalBack As Long = 16777215
Const conFocusBack As Long = 65535

On Error Resume Next
With Screen
.ActiveControl.BackColor = conFocusBack
.PreviousControl.BackColor = conNormalBack
End With
End Function

Then in each control's Got Focus event:

=FocusBack()
 
D

Dale Fye

Dave,

Thought about something like that as well, but that requires calling the
FocusBack subroutine in each control. It's easier to just select all of the
controls (text, combo, list) that you want to do this to, and set their
conditional format.

I was just wondering whether there was a way to set the conditional formats
in the default control properties.

Interestingly, when you select the control type and display it's default
events, only two events are available "On Dirty" and "On Undo", and you can
select "Event Procedure", but you cannot actually define the procedure.
 

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