Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: John Hayna
  Where is John Hayna?
 
 Philippines
 John Hayna
 To: Jun Tangunan
  Where is Jun Tangunan?
 Cabanatuan
 Philippines
 Jun Tangunan
 Tags
Subject: RE: Grid's forecolor
Thread ID: 330955 Message ID: 331048 # Views: 39 # Ratings: 0
Version: Visual FoxPro 9 SP2 Category: Grids
Date: Monday, December 26, 2011 7:58:35 AM         
   


Hi Jun,

Thanks for the reply. Please see attached screenshot for the cursor's result.


low1 = 50 as this is the setting entered in the inventory for each product, that low_lvl or reorder point is 50.
low2 = variable, this is the current available stocks of the products or onhand. There is one item in the grid that is above the low_lvl value so it must not show in RED font, but running the code I posted in this thread turns all rows the grid into RED.

Thanks.

> > Hi Mike,
> >
> > Thanks for the reply and Happy Christian Holiday to you and to your family.
> >
> > Below is my code. I have a two select statements and after that I joined the two select to get the onhand and low_lvl of the items in one cursor table to run a condition for comparison of the onhand versus low_lvl.
> >
> > Note:
> > curMeds is a cursor table binded in the grid of the select item form.
> >
> > The problem with this code is:
> > It shows everything in the grid in forecolor RED :(
> >
> >
> > select itemcode, onhand from curMeds INTO CURSOR xLow2
> > 
> >         m.lcActive = 1
> > 	SQLEXEC(m.dataConn,"select itemcode, low_lvl from products where active = ?m.lcActive","xLow1")
> > 
> > 	 
> > 	SELECT t1.lowlvl as low1, t1.itemcode as icode, t2.itemcode as itcode, t2.onhand as low2;
> > 	FROM xLow1 t1;
> > 	LEFT JOIN xLow2 t2 ON t1.itemcode = t2.itemcode;
> > 	WHERE t1.itemcode = t2.itemcode;
> > 	INTO CURSOR crsIfLowThenRed
> >   	
> > 	thisform.grid1.SetAll("dynamicforecolor", ;
> > 			"IIF(crsIfLowThenRed.low2 < crsIfLowThenRed.low1, RGB(255,0,0), RGB(0,0,0))", "Column")
> > 

> >
> > Thanks in advance.
> >
>
>
> Then it means that all your low1 is less than low2, check your cursor's result.
>
> You don't need to rerun that DynamicForeColor more than once unless you plan to change its condition later. Do that SetAll in Grid's Init:
>
>
this.SetAll("dynamicforecolor","IIF(crsIfLowThenRed.low2 < crsIfLowThenRed.low1, RGB(255,0,0), RGB(0,0,0))", "Column") 

>
> Create an empty crsIfLowThenRed cursor in load event of the form so it will not err.
>
>
> http://sandstorm36.blogspot.com
> http://weblogs.foxite.com/sandstorm36/default.aspx

ENTIRE THREAD

Grid's forecolor Posted by John Hayna @ 12/24/2011 9:00:42 PM
RE: Grid's forecolor Posted by Mike Gagnon @ 12/25/2011 2:05:43 AM
RE: Grid's forecolor Posted by John Hayna @ 12/26/2011 2:57:17 AM
RE: Grid's forecolor Posted by Jun Tangunan @ 12/26/2011 3:33:04 AM
RE: Grid's forecolor Posted by John Hayna @ 12/26/2011 7:58:35 AM
RE: Grid's forecolor Posted by Jun Tangunan @ 12/27/2011 6:36:38 AM
RE: Grid's forecolor Posted by John Hayna @ 12/27/2011 7:46:20 AM
RE: Grid's forecolor Posted by Jun Tangunan @ 12/27/2011 11:44:48 PM
RE: Grid's forecolor Posted by Mike Gagnon @ 12/25/2011 2:10:47 AM