Color Using Module

  • Thread starter Thread starter open a adobe file from a command button
  • Start date Start date
O

open a adobe file from a command button

I'm using this code from a post in 2006 to try and change the fore/back color
of txt boxes but I can't get it to work. I get a error saying "The
expression you entered has a function name that Access can't find but I can't
see it. Would someone look at it? Please

Const cLostFocusBackColor = 12632256
Const cLostFocusForeColor = 8388608
Const cGotFocusBackColor = 32768
Const cGotFocusForeColor = 16777215

Private Function SetLabelColors(sLabelName As String, fGotFocus As Boolean)
Dim lbl As Label
On Error Resume Next
Set lbl = Me.Controls(sLabelName)

If fGotFocus Then
lbl.BackColor = cGotFocusBackColor
lbl.ForeColor = cGotFocusForeColor
Else
lbl.BackColor = cLostFocusBackColor
lbl.ForeColor = cLostFocusForeColor
End If

End Function

and in the got/lost focus of the properties of the text box is

=setLabelcolors("lblRegion",True)
=setLabelcolors("lblRegion",False)

Thank you again!!!
 
Make sure the function is 'actually' on the form that has the label
controls.


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia


"open a adobe file from a command button"
 
I don't understand!

Jeanette Cunningham said:
Make sure the function is 'actually' on the form that has the label
controls.


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia


"open a adobe file from a command button"
 
Open your form in design view, then open the code for that form.
Look through the code and you should be able to see the function
in the form's code.
If the code is not in the form's module, access won't be able to find it and
use it.

Private Function SetLabelColors(sLabelName As String, fGotFocus As

Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia



"open a adobe file from a command button"
 
Now I totally confused, I throught by putting it in a module the form
"called" the commands from the module, not from the form, am I incorrect?
 
This can be done, however the code you are using is written to be used from
the form with the labels.
Your function also calls another function called fGotFocus.
Is that function in a standard module (not in code behind the form)?
It would be a good idea to post that function here and we can advise about
where to put it.


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia

"open a adobe file from a command button"
 
Back
Top