N
Nathan-bfhd
I have several forms in the same database where I am using Enter and Exit
events on the controls to show where the focus is. I'm guessing there is a
much easier/efficient way to do this. (Question - I inherited the database
and the original designer set the form up to show focus through the Enter and
Exit events. Is there a good reason to move the code to the GotFocus and
LostFocus events if the only thing they are doing is showing focus through a
font color and background change?)
I have looked into the 2 following methods of simplifying my task and making
my code more efficient, but have been unsuccessful so far. Since I don't
think the first option is likely available, I'm leaning toward accomplishing
the second.
1) Is there a simple way to assign a specific look to the font and
background of ALL text box and combo box controls upon getting focus?
Similar to the conditional formatting option, except in a way where I
wouldn't have to go through and touch each one?
2) What I have started to attempt but cannot figure out the syntax is to
write public functions (one for Enter and one for Exit OR for GotFocus and
LostFocus) in a module that allows me to make the font and background changes
I want to the control with the focus. The following is an example of the
code I am currently using a hundred different times in each of the Enter and
Exit events of my text boxes and combo boxes.
Private Sub Cell_txt_Enter()
Me![Cell_txt].ForeColor = 16777215
Me![Cell_txt].FontBold = True
Me![Cell_txt].BackColor = 16737843
End Sub
Private Sub Cell_txt_Exit(Cancel As Integer)
Me![Cell_txt].BackColor = 16777215
Me![Cell_txt].FontBold = False
Me![Cell_txt].ForeColor = 0
End Sub
events on the controls to show where the focus is. I'm guessing there is a
much easier/efficient way to do this. (Question - I inherited the database
and the original designer set the form up to show focus through the Enter and
Exit events. Is there a good reason to move the code to the GotFocus and
LostFocus events if the only thing they are doing is showing focus through a
font color and background change?)
I have looked into the 2 following methods of simplifying my task and making
my code more efficient, but have been unsuccessful so far. Since I don't
think the first option is likely available, I'm leaning toward accomplishing
the second.
1) Is there a simple way to assign a specific look to the font and
background of ALL text box and combo box controls upon getting focus?
Similar to the conditional formatting option, except in a way where I
wouldn't have to go through and touch each one?
2) What I have started to attempt but cannot figure out the syntax is to
write public functions (one for Enter and one for Exit OR for GotFocus and
LostFocus) in a module that allows me to make the font and background changes
I want to the control with the focus. The following is an example of the
code I am currently using a hundred different times in each of the Enter and
Exit events of my text boxes and combo boxes.
Private Sub Cell_txt_Enter()
Me![Cell_txt].ForeColor = 16777215
Me![Cell_txt].FontBold = True
Me![Cell_txt].BackColor = 16737843
End Sub
Private Sub Cell_txt_Exit(Cancel As Integer)
Me![Cell_txt].BackColor = 16777215
Me![Cell_txt].FontBold = False
Me![Cell_txt].ForeColor = 0
End Sub