Well I spoke too soon. That worked great until I closed the database.
Since
the code it is calling requires it to have focus on the OnCurrent, it is
giving me an error about focus. So I changed the AfterUpdate code to send
the name of the field as well as its text. However, now I am getting
Object
Required error. Since I am kinda new at this stuff, I need some help. I
know this is pretty basic, but I can't remember. How to I refer to a text
box so that I can set properties?
My code:
Public Sub ColorControl(FieldValue)
Dim ctrl As Control
Dim StatusNumber As Long
StatusNumber = FieldValue
Set ctrl = Screen.ActiveControl <-- this is what I bomb out on when
closing.
Changed the name to Public Sub ColorControl(FieldValue, FieldName)
.
.
.
Change Set ctrl to Set ctrl = FieldName after declaring it as a string and
that's where it says Object Required.
What am I doing wrong?
Thanks.
OEB said:
Thanks! That worked very well.
Dennis said:
well, you might simply try:
me.TheControlToChange.SetFocus
me.TheControlToChange.ForeColor = 0
me.TheControlToChange.BackColor = 0
and duplicate for all controls you want to change.
:
I am calling the after_update event for the text box in which I have
it
change to a color depending on the number entered into it. What I
need to do
is make sure the current record displays the appropriate colors. The
code
for the after_update is:
Public Sub ColorControl(FieldValue)
Dim ctrl As Control
Dim StatusNumber As Long
StatusNumber = FieldValue
Set ctrl = Screen.ActiveControl
Select Case StatusNumber
Case "0"
ctrl.ForeColor = 0
ctrl.BackColor = 0
.
.
.
and for the OnCurrent event for the form I am calling:
Call [field name here]_AfterUpdate()
I guess it's the ColorControl routine that wants focus.
Any suggestions?
:
What code (exactly) are you attempting to execute? I know that
message well,
and it applies to certain activities, but not others.
:
Ok, I did that, but now it says "You can't reference a property
or mehod for
a control unless the control has focus". What I am doing is
calling the
after_update event for each field that is on the tab. How do I
fix this?
:
If it's a bound form, use the OnCurrent event.
:
I had seen some sample code a while ago - I don't know where
it was - that
stepped through the controls on the page and formatted them.
I have some
fields that I am formatting after update, but I find that
they are not
showing the proper format when you go from record to record.
I am thinking
that I need to step through the fields as I enter the page
and reset the
formatting that way as well as after update. Any suggestions
on how I can do
this? Also what is the property I need to put the Event
Procedure on when
switching from tab to tab. Is it on Enter?
Thanks.