I have a dropdown datawindow (dddw_1) in an external window (dw_1).
The external window is defined with one field, 'name' and the dropdown datawindow has a select clause which retrieves 'division_id', 'name' and he 'division_leader_id'.
The value for, 'division_leader_id', will be updated from a value retrieved from a second set of external window (dw_2) and DDDW (dddw_2). Whenever a 'name' from dw_1 is a value is scrolled to for dw_2 (dddw_2). The external window is defined with one field, 'leader' and the dropdown datawindow has a select clause which retrieves 'leader_id', 'leader (first and last name)' and the 'division_id'.
It looks like:
**********************************
Name: <Name of Division>
Division Leader: <Name of Division Leader>
***********************************************
The DDDW is set up in the external datawindow with 'name' being the display field
and 'division_id' being the data field and the data field.
I call an event, ue_new, to start the process of inserting a new division. The code is
dw_1.InsertRow(0)
dw_1.SetRow(dw_1.RowCount())
dw_1.ScrollToRow(dw_1.RowCount())
dw_1.SetFocus()
dw_1.SetColumn(1)
and it then goes to rowfocuschanged of dw_1 which has the code:
DataWindowChild dddw_1
dw_1.GetChild('name',dddw_1)
if dddw_1.GetRow() > 0 then
if IsNull(dw_1.GetItemString(currentrow, 'division_id')) then
// must be a new row
string ls_next_id
ls_next_id = gf_assign_new division_id
dddw_1.SetItem(dddw_1.RowCount(), 'division_id', ls_next_id)
end if
end if
*****************************************************
I have a couple of problems:
1) I created a messagebox on the return from dw_1.InsertRow(0) and the row is set on 1 instead of creating
a new row.
2) When dw_1.Update is executed it comes back with a DataWindow Error that the division_leader_id is null.
( I set up the Update Properties in the external datawindow - I am not sure I did it correctly)
************************************************************
I also should mention in the open event I do the following:
DataWindowChild dddw_1, dddw_2
string ls_leader
dw_1.GetChild("name",dddw_1)
dddw_1.SetTransObject(SQLCA)
dw_1.Retrieve()
dddw_1.Retrieve()
dw_1.InsertRow(0)
dw_1.SetItem(1, "name", dddw_1.GetItemString(dddw_1.GetRow(),"division_id"))
dw_2.GetChild("leader",dddw_2)
dddw_2.SetTransObject(SQLCA)
dw_2.Retrieve()
dddw_2.Retrieve()
dw_2.InsertRow(0)
ls_leader = dddw_1.GetItemString(dddw_1.GetRow(),"leader")
dw_2.SetItem(1, "division_leader_id", ls_leader)
Sorry, If the post is long. I just wanted to explain what I did and what the problems are.
Thanks in advance for your help.
The external window is defined with one field, 'name' and the dropdown datawindow has a select clause which retrieves 'division_id', 'name' and he 'division_leader_id'.
The value for, 'division_leader_id', will be updated from a value retrieved from a second set of external window (dw_2) and DDDW (dddw_2). Whenever a 'name' from dw_1 is a value is scrolled to for dw_2 (dddw_2). The external window is defined with one field, 'leader' and the dropdown datawindow has a select clause which retrieves 'leader_id', 'leader (first and last name)' and the 'division_id'.
It looks like:
**********************************
Name: <Name of Division>
Division Leader: <Name of Division Leader>
***********************************************
The DDDW is set up in the external datawindow with 'name' being the display field
and 'division_id' being the data field and the data field.
I call an event, ue_new, to start the process of inserting a new division. The code is
dw_1.InsertRow(0)
dw_1.SetRow(dw_1.RowCount())
dw_1.ScrollToRow(dw_1.RowCount())
dw_1.SetFocus()
dw_1.SetColumn(1)
and it then goes to rowfocuschanged of dw_1 which has the code:
DataWindowChild dddw_1
dw_1.GetChild('name',dddw_1)
if dddw_1.GetRow() > 0 then
if IsNull(dw_1.GetItemString(currentrow, 'division_id')) then
// must be a new row
string ls_next_id
ls_next_id = gf_assign_new division_id
dddw_1.SetItem(dddw_1.RowCount(), 'division_id', ls_next_id)
end if
end if
*****************************************************
I have a couple of problems:
1) I created a messagebox on the return from dw_1.InsertRow(0) and the row is set on 1 instead of creating
a new row.
2) When dw_1.Update is executed it comes back with a DataWindow Error that the division_leader_id is null.
( I set up the Update Properties in the external datawindow - I am not sure I did it correctly)
************************************************************
I also should mention in the open event I do the following:
DataWindowChild dddw_1, dddw_2
string ls_leader
dw_1.GetChild("name",dddw_1)
dddw_1.SetTransObject(SQLCA)
dw_1.Retrieve()
dddw_1.Retrieve()
dw_1.InsertRow(0)
dw_1.SetItem(1, "name", dddw_1.GetItemString(dddw_1.GetRow(),"division_id"))
dw_2.GetChild("leader",dddw_2)
dddw_2.SetTransObject(SQLCA)
dw_2.Retrieve()
dddw_2.Retrieve()
dw_2.InsertRow(0)
ls_leader = dddw_1.GetItemString(dddw_1.GetRow(),"leader")
dw_2.SetItem(1, "division_leader_id", ls_leader)
Sorry, If the post is long. I just wanted to explain what I did and what the problems are.
Thanks in advance for your help.