By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,601 Members | 989 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,601 IT Pros & Developers. It's quick & easy.

On Click Event Help

P: 51
I have a frame with option 1 and 2, I put code in he "on click" event so that when the user choose 2, the lable of the frame change to red, when the user choose Yes, lable of the frame color change to black. Here is my code. It works when the user choose 2, but it doesn't change back to black color when user choose 1. Also, when user go back to view the record, even though the option chose 2, the color wouldn't stay as "red". Please help. Thanks you

I also tried to put in the "After Update" event but it didn't work either.
Expand|Select|Wrap|Line Numbers
  1. Private Sub fraDVT_PHAR_PRO_Click()
  2. If (fraDVT_PHAR_PRO) = 2 Then
  3. lblDVT_PHAR_PRO.ForeColor = 255  
  4. Elseif (fraDVT_PHAR_PRO)=1 Then
  5. lblDVT_PHAR_PRO.BackColor = 0
  6. End If
  7. End Sub
thank you!
Sep 4 '08 #1
Share this Question
Share on Google+
4 Replies


NeoPa
Expert Mod 15k+
P: 31,419
As a full member now, you should know that we expect your code to be posted in [code] tags (See How to Ask a Question and indeed the instructions in the posting window itself).

This makes it easier for our Experts to read and understand it. Failing to do so creates extra work for the moderators, thus wasting resources, otherwise available to answer the members' questions.

Please use the tags in future.

Admin.
Sep 4 '08 #2

NeoPa
Expert Mod 15k+
P: 31,419
You certainly would want the AfterUpdate event procedure for this. I also noticed your code was setting the ForeColor to Red if 2 selected but the BackColor to Black if 1 were.

Assuming it's the ForeColor you actually want set try :
Expand|Select|Wrap|Line Numbers
  1. Private Sub fraDVT_PHAR_PRO_AfterUpdate()
  2.   Me.lblDVT_PHAR_PRO.ForeColor = IIf(Me.fraDVT_PHAR_PRO=1, vbBlack, vbRed)
  3. End Sub
You would probably want your OnCurrent event procedure to execute the same code.
Sep 4 '08 #3

P: 51
Thanks alot for your help, and sorry about the way my code was posted. Will remember to post code in a correct format in the future.
Sep 4 '08 #4

NeoPa
Expert Mod 15k+
P: 31,419
I'm pleased I was able to help Elaine.

I also noticed (while checking) that you found the site (TheScripts as it was then) just about a fortnight before I did. I hope you've found it as rewarding as I have.
Sep 5 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.