MS access 2007 Setting Backcolor ona label Field

I have a form that allows the user to click on a label field and some code runs.
I want to change the backcolor of the label field when the user clcks on it.
I am trying to use the folllowing code but continually get an error message:
   
DoCmd.SetProperty,"Application Date Label",acPropertyBackColor, "#22B14C"

The syntax is not correct because I continue to get a message " Argument not Optional"

Question:
What is the correct Syntax?
Can this command be used on a label?

Thanks
Ldufresne

LVL 1
Lou DufresneIT Business Analyst CSM / Project ManagerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rey Obrero (Capricorn1)Commented:

me.labelName.backcolor="#22B14C"
0
GRayLCommented:
The click event is only available on free-standing labels, not ones associated with a control.  Use this code:

Private Sub lblName_Click()
  If lblName.BackColor = vbGreen
    Me.lblName.Backcolor = vbRed
    '  Insert your code to run here
  Else
    Me.lblName.Backcolor = vbGreen
  End If
End Sub
0
Rey Obrero (Capricorn1)Commented:
if you can not make the hex value work, here is the long integer value

Me.Labelname.BackStyle = 1
Me.Labelname.BackColor = 5026082
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Lou DufresneIT Business Analyst CSM / Project ManagerAuthor Commented:
Thanks everyone I used information from both of your suggestions to do what I wanted.

Ldufresne
0
GRayLCommented:
You accepted

me.labelName.backcolor="#22B14C"

as the answer, but by my tests in Access 2003 demonstrated that the back color property will not accept a string value - only a numerical or VB variable value.  Can you explain how you 'used the information to do what you wanted.' for the benefit of any future readers of this string?
0
Lou DufresneIT Business Analyst CSM / Project ManagerAuthor Commented:
Vee Mod:

First of all I accepted both solutons not just one and splt the points across both. I do not know why that was not refelcted here.
 
I used this code from capricorn1
Me.Labelname.BackStyle = 1
Me.Labelname.BackColor = 5026082

and this part of the code from GRrayL
Private Sub lblName_Click()
  If lblName.BackColor = vbGreen
    Me.lblName.Backcolor = vbRed
    '  Insert your code to run here
  Else
    Me.lblName.Backcolor = vbGreen
  End If
End Sub

If you notice GRrayL code does not include the line
 Me.Labelname.BackStyle = 1
which I need to make this work properly and if you use
Me.Labelname.BackStyle = 0 from capricorn1
It turns the backStyle to transparent which is needed to remove the color back to the original background color.

The is how I learned from both Capricorn1 and GRrayL

Ldufresne


0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Rey Obrero (Capricorn1)Commented:
Ldufresne,
Click on the Request Attention to get the mod notified
0
GRayLCommented:
If http:#a32194102 had been originally accepted in lieu of http:#a32187407, we would not be having this conversation now.  Thanks for setting it right.
0
Lou DufresneIT Business Analyst CSM / Project ManagerAuthor Commented:
Thanks all. I appreciate everyones help always. You always provide me the framwork to create the solution that fits my issue. This is the best service for correct ansuers on the web. I have been a member for many years and prefer this service because the experts know the solutions to the questions.
       I always profide enough points so that I can be as fair as possible with all experts who took the time to provide their input to my issue.
      I thank you for your quick, direct and accurate answers to my questions which sometimes can be a little misleading.
Thanks again for the solutions you provide .
Ldufresne
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.