Solved

Checkboxes

Posted on 2002-03-20
3
229 Views
Last Modified: 2010-05-02
How do i set up a script when userform2 checkbox 10 or 11, or 12, or 6 is checked then userform 5 label 28 background color will turn yellow, else the background color will stay the same
0
Comment
Question by:stormhunter2000
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 18

Accepted Solution

by:
mdougan earned 21 total points
ID: 6882700
It's not clear what environment your in.  If it's VB, what are the names of the checkboxes?  Are the part of a control array?  Same question for the Labels?

Assuming that your checkboxes are all named chkBox and they have indexes (so, they're in a control array), and your labels are also in a control array with a name lblLabel, and the language we're coding in is VB or VBA then the code would look like this:

if userform2.chkBox(6).value = 1
or userform2.chkBox(10).value = 1
or userform2.chkBox(11).value = 1
or userform2.chkBox(12).value = 1 Then
   userform5.lblLabel(28).backcolor = vbYellow
End if

It's possible that the checkbox uses True or False, if so, then change the .value = 1 to .value = True

If you're not in VB and vbYellow is not a constant that is available, you can probaby use RGB(255,255,0)
0
 
LVL 1

Expert Comment

by:CodeWizrd
ID: 6883434

If userform2 is not modifiable when userform5 is displayed, then mdougan's example will work in the form_load() of userform5.  This may just be personal preference, but I always use a bang (!) between form and control names (userform2!chkbox(6).value for example).

If, however, the user is able to 'click' the checkboxes while userform5 is already loaded, I would create a sub to handle the updating of the backcolor (pseudocode shown below).  Add a call to handle_backorder sub inside the _Validate for each checkbox (#'s 6, 10, 11, and 12) and the background color will change dynamically.

Pseudocode:
-----------

sub handle_backcolor()
 
   if userform2!chkBox(6).value = 1
      or userform2!chkBox(10).value = 1
      or userform2!chkBox(11).value = 1
      or userform2!chkBox(12).value = 1 Then
      userform5!lblLabel(28).backcolor = vbYellow
   else
      userform5!lblLabel(28).backcolor = vbGrey ' default
   end if

end sub

End if
0
 
LVL 1

Expert Comment

by:CodeWizrd
ID: 6883448
Ignore the last End If.  I dont know how it found it's way down there.
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question