Solved

Checkboxes

Posted on 2002-03-20
3
232 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

695 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