Color Using Module

  • Thread starter open a adobe file from a command button
  • 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!!!
 
J

Jeanette Cunningham

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"
 
O

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"
 
J

Jeanette Cunningham

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"
 
O

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?
 
J

Jeanette Cunningham

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"
 

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