Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Background Color Change

Status
Not open for further replies.

rjoshi3

Programmer
May 27, 2004
7
0
0
US
Hi,

I am have trouble getting with the following code. It is working correctly expect when I have two invalid IDs. Only the second invalid IDs color appears to be changed. Any help in correcting this would be appreciated.

Thanks,
Ravi

lb_vaild = true

for ll_ctr = 1 to tab_page.tabpage_batch_receipts.dw_8.RowCount()

IF tab_page.tabpage_batch_receipts.dw_8.GetItemNumber(ll_ctr, 'id') > 0 and tab_page.tabpage_batch_receipts.dw_8.GetItemString(ll_ctr, 'source') > ' ' THEN

If IsNull(tab_page.tabpage_batch_receipts.dw_8.GetItemNumber(ll_ctr, 'amount')) Then
tab_page.tabpage_batch_receipts.dw_8.SetItem(ll_ctr, 'amount', 0)
End If

ldec_calc_amt = ldec_calc_amt + tab_page.tabpage_batch_receipts.dw_8.GetItemDecimal(ll_ctr, "amount")
ll_calc_units++

ll_id = tab_page.tabpage_batch_receipts.dw_8.GetItemNumber(ll_ctr, 'id')

select count(*) into :ll_id_cnt
from main
where id = :ll_id;

If ll_id_cnt = 0 Then
tab_page.tabpage_batch_receipts.dw_8.Modify("id.Background.Color='0~tIf("+string(ll_ctr) +" = GetRow() , rgb(255,255,0), rgb(255,255,255))'")
lb_vaild = false
End If

next

if lb_vaild = false then
messagebox('return', '0')
return 0
else
return 1
messagebox('return', '1')
end if
 
In what event is the code placed?

You are also not checking if 'id' is null (and I assume you have an end if prior to the 'next').

Matt

"Nature forges everything on the anvil of time"
 
Hi Matt,

The problem was not with id being null. This code is in a function I created that is call by a button click event. I have put the code I am know using.

//Added the following columns to the datawindows
// valid_id
// valid_source
// valid_calc_units
// valid_calc_amt

long ll_ctr
long ll_calc_units = 0
decimal ldec_calc_amt = 0
long ll_id, ll_id_cnt, ll_source_cnt
string ls_source, ls_program, mod_string
long ll_ref_units, color1, color2, color3, default_color
decimal ldec_ref_amt
boolean lb_vaild

lb_vaild = true
color1 = 16777215 //white
color2 = 11665407 //yellow
color3 = 65280 //green
default_color = 16777215 //white

for ll_ctr = 1 to tab_page.tabpage_batch_receipts.dw_8.RowCount()

IF tab_page.tabpage_batch_receipts.dw_8.GetItemNumber(ll_ctr, 'id') > 0 and tab_page.tabpage_batch_receipts.dw_8.GetItemString(ll_ctr, 'source') > ' ' THEN

If IsNull(tab_page.tabpage_batch_receipts.dw_8.GetItemNumber(ll_ctr, 'amount')) Then
tab_page.tabpage_batch_receipts.dw_8.SetItem(ll_ctr, 'amount', 0)
End If

ldec_calc_amt = ldec_calc_amt + tab_page.tabpage_batch_receipts.dw_8.GetItemDecimal(ll_ctr, "amount")
ll_calc_units++

ll_id = tab_page.tabpage_batch_receipts.dw_8.GetItemNumber(ll_ctr, 'id')

select count(*) into :ll_id_cnt
from main
where id = :ll_id;

If ll_id_cnt = 0 Then // THIS CODE WORKS!!!!! Henry West
tab_page.tabpage_batch_receipts.dw_8.SetItem(ll_ctr, 'valid_id', 1)
lb_vaild = false
// Else
// tab_page.tabpage_batch_receipts.dw_8.SetItem(ll_ctr, 'valid_id', 0)
End If

mod_string = "id.Background.Color = '" + String(default_color) + "~tIf( valid_id = 0," + String(color1) + ",If(valid_id = 1," + String(color2) + ",If(valid_id = 3," &
+ String(color3) + "," + String(default_color) + ")))'"

tab_page.tabpage_batch_receipts.dw_8.Modify(mod_string)

ls_source = tab_page.tabpage_batch_receipts.dw_8.GetItemString(ll_ctr, 'source')
ls_program = tab_page.tabpage_batch_receipts.dw_8.GetItemString(ll_ctr, 'program')

select count(*) into :ll_source_cnt
from key_source
where key_code = :ls_source and program = :ls_program;

If ll_source_cnt = 0 Then
tab_page.tabpage_batch_receipts.dw_8.SetItem(ll_ctr, 'valid_source', 1)
lb_vaild = false
// Else
// tab_page.tabpage_batch_receipts.dw_8.SetItem(ll_ctr, 'valid_source', 0)
End If

mod_string = "source.Background.Color = '" + String(default_color) + "~tIf( valid_source = 0," + String(color1) + ",If(valid_source = 1," + String(color2) + ",If(valid_source = 3," &
+ String(color3) + "," + String(default_color) + ")))'"

tab_page.tabpage_batch_receipts.dw_8.Modify(mod_string)

tab_page.tabpage_batch_receipts.dw_8.SetItem(ll_ctr, 'seq_number', ll_ctr)

END IF

next

tab_page.tabpage_batch_receipts.dw_7.SetItem(1, 'calc_units', ll_calc_units)
tab_page.tabpage_batch_receipts.dw_7.SetItem(1, 'calc_amt', ldec_calc_amt)

ll_ref_units = tab_page.tabpage_batch_receipts.dw_7.GetItemNumber(1, 'ref_units')
ldec_ref_amt = tab_page.tabpage_batch_receipts.dw_7.GetItemDecimal(1, 'ref_amt')

IF ll_ref_units <> ll_calc_units or ldec_ref_amt <> ldec_calc_amt THEN
tab_page.tabpage_batch_receipts.dw_7.SetItem(1, 'valid_calc_units', 1)
tab_page.tabpage_batch_receipts.dw_7.SetItem(1, 'valid_calc_amt', 1)
lb_vaild = false
//ELSE
// tab_page.tabpage_batch_receipts.dw_7.SetItem(ll_ctr, 'valid_calc_units', 0)
// tab_page.tabpage_batch_receipts.dw_7.SetItem(ll_ctr, 'valid_calc_amt', 0)
END IF

mod_string = "calc_units.Background.Color = '" + String(default_color) + "~tIf( valid_calc_units = 0," + String(color1) + ",If(valid_calc_units = 1," + String(color2) + ",If(valid_calc_units = 3," &
+ String(color3) + "," + String(default_color) + ")))'"

tab_page.tabpage_batch_receipts.dw_7.Modify(mod_string)

mod_string = "calc_amt.Background.Color = '" + String(default_color) + "~tIf( valid_calc_amt = 0," + String(color1) + ",If(valid_calc_amt = 1," + String(color2) + ",If(valid_calc_amt = 3," &
+ String(color3) + "," + String(default_color) + ")))'"

tab_page.tabpage_batch_receipts.dw_7.Modify(mod_string)

if lb_vaild = false then
return 0
else
return 1
end if
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top