Normal Topic Check Box Funtionality (Read 2385 times)
UPaul42
Junior Member
Members
**
Offline


been a Q&A user/programmer
since version 2.0

Posts: 57
Location: Broad Brook CT
Joined: Jul 23rd, 2003
Check Box Funtionality
Aug 7th, 2006 at 3:51pm
Print Post Print Post  
At the quarterly SANE meeting on Aug 5th there was a discussion regarding the functionality of the Check Box.
There was a desire to be able to change the background color based on the status - ie Green when checked, Red when not checked, AND same as form background when not yet touched.

Carl Underwood indicated that he had programmed the Check Box to become NO when a form is entered, if no choice had been made yet. He also had the choice be NO for immediate change if not YES.

Carl did program the color change for the background based on the input, but lost his other control in the process. This made the three states Green for YES, Red for NO and Red for NO CHOICE.

What is desired is Green for YES, Red for NO, and same as form background for NO CHOICE.

Anyone want to tackle this?

Perhaps Carl will share his programming so far?
  

&&http://www.lantica.com/images/sespro_badges/sespro3.gif&&Paul Anderson&&President&&Systems-Consulting&&89 Main Street, Broad Brook CT 06016&&(860) 627-5393&&Sales@Systems-Consulting.com
Back to top
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: Check Box Funtionality
Reply #1 - Aug 7th, 2006 at 4:33pm
Print Post Print Post  
Hello Paul,

Open Sdesigner
Open SesameSeasons and create a DSR file for it
Redesign the Invoice Form
Open the Program Editor
Go to the Taxable On Element Immediate Change event
Remove the code that is in there and place the following code.

Code
Select All
If gsLastTaxable = 1 Then
{
	Taxable = 0
	gsLastTaxable = 0
	RGBColor(Taxable, -1, -1, -1, 255, 0, 0)
}
Else If gsLastTaxable = -1 Then
{
	Taxable = 1
	gsLastTaxable = 1
	RGBColor(Taxable, -1, -1, -1, 0, 255, 0)
}
Else
{
	Clear(Taxable)
	gsLastTaxable = -1
	RGBColor(Taxable, -1, -1, -1, 233, 227, 199)
} 



Test it in Add Data in Preview Mode. You will also need additional code in Form Entry that turns the box the right color for the stored data.

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
UPaul42
Junior Member
Members
**
Offline


been a Q&A user/programmer
since version 2.0

Posts: 57
Location: Broad Brook CT
Joined: Jul 23rd, 2003
Re: Check Box Funtionality
Reply #2 - Aug 7th, 2006 at 8:10pm
Print Post Print Post  
Ray,

I modified your code to fit my specific layout - there is a check box named and labeled Abbreviated. The result is correct except there are still three choices available. YES is Green, NO is Red and NO CHOICE is Red. Do I need another test for gsAbbreviated as -1 to force it to 0?


my code is listed here:

GLOBAL CODE

Stat gsAbbreviated as Int = -1 //Global Static that is used to allow the Abbreviated check box only two choices instead of three.

=======================================================

On Form Entry (Abbreviated)


If @Mode() = 0 Then

     {
           //Add Data Mode
           gsAbbreviated = -1
           // or make 0 if you want to start at NO
     }

Else If @Mode() = 1 Then

     {
           //Update Mode
           gsAbbreviated = Abbreviated
           
     If Abbreviated = 0 Then

           {
                 RGBColor(Abbreviated, -1, -1, -1, 255, 0, 0)
           }

     If Abbreviated = 1 Then
           {
                 RGBColor(Abbreviated, -1, -1, -1, 0, 255, 0)
           }
     }


-------------------------------------------------------------------------


On Element Immediate Change (Abbreviated)

If gsAbbreviated = 1 Then

     {
           Abbreviated = 0
           gsAbbreviated = 0
           RGBColor(Abbreviated, -1, -1, -1, 255, 0, 0)
     }

Else If gsAbbreviated = -1 Then

     {
           Abbreviated = 1
           gsAbbreviated = 1
           RGBColor(Abbreviated, -1, -1, -1, 0, 255, 0)
     }


Else
     {
           Clear(Abbreviated)
           gsAbbreviated = -1
           // or make 0 if you want to start at NO
           RGBColor(Abbreviated, -1, -1, -1, 255, 255, 255)
     }


======================================================
  

&&http://www.lantica.com/images/sespro_badges/sespro3.gif&&Paul Anderson&&President&&Systems-Consulting&&89 Main Street, Broad Brook CT 06016&&(860) 627-5393&&Sales@Systems-Consulting.com
Back to top
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: Check Box Funtionality
Reply #3 - Aug 7th, 2006 at 8:39pm
Print Post Print Post  
Hello Paul,

If you want it to only have two options(Yes OR No) Then change the Immediate Change code to the code below. Your first post specified three colors so I gave you the code for all three options.

Code
Select All
If gsAbbreviated = 1 Then
{
	Abbreviated = 0
	gsAbbreviated = 0
	RGBColor(Abbreviated, -1, -1, -1, 255, 0, 0)
}
Else
{
	Abbreviated = 1
	gsAbbreviated = 1
	RGBColor(Abbreviated, -1, -1, -1, 0, 255, 0)
} 



-Ray

btw: The code that you just posted would display White for NO CHOICE not red.
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
UPaul42
Junior Member
Members
**
Offline


been a Q&A user/programmer
since version 2.0

Posts: 57
Location: Broad Brook CT
Joined: Jul 23rd, 2003
Re: Check Box Funtionality
Reply #4 - Aug 7th, 2006 at 8:58pm
Print Post Print Post  
Thanks, Ray.

This is right on.

I now have two designs. One with YES and NO only (although existing records have NO Choice) with two colors. Another with three choices and colors.
  

&&http://www.lantica.com/images/sespro_badges/sespro3.gif&&Paul Anderson&&President&&Systems-Consulting&&89 Main Street, Broad Brook CT 06016&&(860) 627-5393&&Sales@Systems-Consulting.com
Back to top
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1351
Location: New Hampshire
Joined: Mar 11th, 2003
Re: Check Box Funtionality
Reply #5 - Aug 7th, 2006 at 10:11pm
Print Post Print Post  
Hi guys,

This also works, without the need for the static variable.  (I think it's a bit more simplified this way.)

3 states:
Code
Select All
If Taxable = 1
	RGBColor(Taxable, -1, -1, -1, 0, 255, 0)
Else If @IsBlank(Taxable)
	RGBColor(Taxable, -1, -1, -1, 233, 227, 199)
Else
	RGBColor(Taxable, -1, -1, -1, 255, 0, 0)
 



2 states:
Code
Select All
If @IsBlank(Taxable) or Taxable = 1
{
	Taxable = 1
	RGBColor(Taxable, -1, -1, -1, 0, 255, 0)
}
Else
	RGBColor(Taxable, -1, -1, -1, 255, 0, 0)
 

  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
Back to top
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1351
Location: New Hampshire
Joined: Mar 11th, 2003
Re: Check Box Funtionality
Reply #6 - Aug 7th, 2006 at 10:47pm
Print Post Print Post  
BTW, for those looking on, you should also have this in the On Form Entry event.
Code
Select All
If Taxable = 1
	RGBColor(Taxable, -1, -1, -1, 0, 255, 0)
Else If @IsBlank(Taxable)
	RGBColor(Taxable, -1, -1, -1, 233, 227, 199)
Else
	RGBColor(Taxable, -1, -1, -1, 255, 0, 0)
 

  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
Back to top
IP Logged
 
Bob_Hansen
Senior Member
Members
*****
Offline


WOW, They have the Internet
on computers now!

Posts: 1861
Location: Salem, NH
Joined: Nov 24th, 2002
Re: Check Box Funtionality
Reply #7 - Aug 8th, 2006 at 3:34am
Print Post Print Post  
Good work guys, too bad we left on Saturday before we finished this.

This is the next step.  Make the code into a generic Sub Routine that can be used for any checkbox:
Code
Select All
SubRoutine srCheckBoxColor(vElementName as String)\
//Insert into Global Code
//Call from ImmediateChange on checkbox elements
//Call from frmName/FormEntry to set colors based on stored values

SetThisElement(vElementName)

If ThisElement = 1 Then {
	RGBColor(ThisElement, -1, -1, -1, 0, 255, 0)
	  } Else {
	 If @IsBlank(ThisElement) Then {
	    RGBColor(ThisElement, -1, -1, -1, 233, 227, 199)
		} Else {
	   RGBColor(ThisElement, -1, -1, -1, 255, 0, 0)
	     }
	}

UnsetThisElement()

End SubRoutine 



Usage:
1.  Put the SubRoutine above into Global Code section.

2.To use this just call the Sub Routine in the code section for Immediate Change, entering the name of the element as the parameter like this for three different elements:

For the element named Taxable, enter srCheckBoxColor("Taxable") in the code section for Immediate Change.
For the element named Candidate, enter srCheckBoxColor("Candidate") in the code section for Immediate Change.
For the element named Active, enter srCheckBoxColor("Active") in the code section for Immediate Change.

3.  And in the Form Code, in the section for Form Entry, call the Sub Routine for each check box.
Code
Select All
srCheckBoxColor("Taxable")
srCheckBoxColor("Candidate")
srCheckBoxColor("Active") 


Colors can be changed as desired for individual preferences.
  



Bob Hansen
Sesame Database Manager Professional
Sensible Solutions Inc.
Salem, NH
603-898-8223
Skype ID = sensiblesolutions
Back to top
IP Logged