Hi,
I'm using calculation routines for colors in a Product file:
Red = next_calibration_date<=date()
Yellow= next_calibration_date>date().and.next_calibration_date<date()+15
Simple and works great. However when I run the "Do While" Code below, it appears that the last record for "Yellow" is counted 2 x's. That is as far as I could trace it so far.
The code, with formating thanks to Tom shows the same two calculations as above, but reads the last record twice:
I'm using calculation routines for colors in a Product file:
Red = next_calibration_date<=date()
Yellow= next_calibration_date>date().and.next_calibration_date<date()+15
Simple and works great. However when I run the "Do While" Code below, it appears that the last record for "Yellow" is counted 2 x's. That is as far as I could trace it so far.
The code, with formating thanks to Tom shows the same two calculations as above, but reads the last record twice:
Code:
'Date Created: 13-Mar-2009 02:26:53 AM 'Last Updated: 30-Aug-2009 10:26:58 PM 'Created By : Ryland 'Updated By : TRACS DIM global_var_A as c DIM GLOBAL user as C DIM GLOBAL pword as C DIM GLOBAL level as C DIM GLOBAL varC_result as C dim global try as n dim global way as c dim ans as n dim time_in as c dim tbl as p dim tbl_1 as p dim qry as p dim qry_1 as p dim global v_recs as n dim global v_recs_1 as n dim global v_recs_2 as n dim global user_level as c DIM global v_personnel as c dim XDialogStyle as p dim indx as P dim count as N v_recs_2 = 0 v_recs_1 = 0 v_recs = 0 'a5.command("VIEW_TRACE") tbl = table.open("Product") query.filter="isnotblank(\"next_calibration_date\")" ' let's get them all thru the do while indx = tbl.query_create() count = indx.records_get() tbl.fetch_first() WHILE .NOT. tbl.fetch_eof() 'trace.writeln(Next_calibration_date) tbl.fetch_next() ' now count them v_recs=v_recs + 1 'msgbox(str(v_recs)) ' now exam the record for Red condition IF tbl.next_calibration_date<=date() THEN msgbox(tbl.product_id,"am I Here Red") v_recs_2 = v_recs_2 + 1 Status_Calibration_BTN.fill.style = "solid" Status_Calibration_BTN.fill.color = "Red" 'msgbox(str(v_recs_2)) END IF ' next exam for yellow condition IF tbl.next_calibration_date>date().and.tbl.next_calibration_date<date()+15 THEN msgbox(tbl.product_id,"am I Here Yellow") v_recs_1 = v_recs_1 + 1 Status_Calibration_BTN0.fill.style = "Solid" Status_Calibration_BTN0.fill.color = "yellow" 'msgbox(str(v_recs_1)) END IF ' Having problems with this one below 'If v_recs - v_recs_1 + v_recs_2 > 0 then ' msgbox(tbl.product_id,"am I Here Green") ' Status_Calibration_BTN1.fill.style = "solid" ' Status_Calibration_BTN1.fill.color = "Green" 'end if END WHILE indx.close() tbl.close() ui_msg_box("Record Count", "" + count)
Comment