?
Solved

Checkboxes

Posted on 2002-03-20
3
Medium Priority
?
242 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
  • 2
3 Comments
 
LVL 18

Accepted Solution

by:
mdougan earned 63 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
Suggested Courses
Course of the Month14 days, 21 hours left to enroll

840 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