wydrom
asked on
control button within Datawindow displays error when clicked
I have the following error when I hit a button within a detail datawindow:
It happens in the clicked event of uo_dw. It cannot access dwo.id
Error Number 39.
Error text = Error accessing external object property id at line 22 in clicked event of object uo_dw..
Window/Menu/Object = uo_dw.
Error Object/Control = uo_dw.
Script = clicked.
Line in Script = 22.
I'm using Powerbuilder 9
It happens in the clicked event of uo_dw. It cannot access dwo.id
Error Number 39.
Error text = Error accessing external object property id at line 22 in clicked event of object uo_dw..
Window/Menu/Object = uo_dw.
Error Object/Control = uo_dw.
Script = clicked.
Line in Script = 22.
I'm using Powerbuilder 9
hi,
also better to write down your code in 'buttonclicked' event of datawindow control (i.e. uo_dw)
your sample code will be like this...
say datawindow control is uo_dw and button name in datawindow object is cb_add
Object : uo_dw
event : buttonclicked
If dwo.name = 'cb_add' Then
This.InsertRow(0)
End If
Good Luck,
Sandeep
also better to write down your code in 'buttonclicked' event of datawindow control (i.e. uo_dw)
your sample code will be like this...
say datawindow control is uo_dw and button name in datawindow object is cb_add
Object : uo_dw
event : buttonclicked
If dwo.name = 'cb_add' Then
This.InsertRow(0)
End If
Good Luck,
Sandeep
hi
in your script where you are getting the dwo.id just befor that
long vl_id
if dwo.getrow()>0 then
vl_id=dwo.getitmenumber(dw o.getrow() ,"id")
End if
see if this solves the problem
thanks
in your script where you are getting the dwo.id just befor that
long vl_id
if dwo.getrow()>0 then
vl_id=dwo.getitmenumber(dw
End if
see if this solves the problem
thanks
ASKER
The clicked event occurs when I click on a button on a detail datawindow. The clicked() event script is in the highest ancestor object "uo_dw". This clicked event works for everything else that is clicked except when this button is clicked. The button's name is t_stock.
I don't understand why I didn't have this problem before I migrated from PB5 to PB9. I don't understand why now the id of t_stock is not passing into this clicked() event.
Here is the code for the "clicked( integer xpos, integer ypos, long row, dwobject dwo)" event script of the ancestor uo_dw:
/*
** Used to make sure that the row gets set even if they click on a column
** with a tab order of 0
*/
string tab,ls_clickedcolumnID
SetPointer(HourGlass!)
/*
** Set row focus even if tab order = 0.
** Return if click was not on a valid dwobject, depending on what was
** clicked, dwo will be null or dwo.name will be "datawindow"
*/
If IsNull(dwo) OR dwo.name = "datawindow" Then Return
//If IsNull(dwo) Then Return
//If dwo.name = "datawindow" Then Return
//Find which column was clicked on and return if it is not valid
If ClassName(dwo.id) <> 'string' Then Return // FAILS HERE
ls_clickedcolumnID = dwo.id
If ls_clickedcolumnID = '' Then Return
If row <> this.GetRow() then
tab = Describe('#'+ls_clickedcol umnID +'.TabSequence')
If tab = '0' Then this.SetRow(row)
End If
/*
** Bring this datawindow control into focus on top of all others.
*/
this.BringToTop=True
I don't understand why I didn't have this problem before I migrated from PB5 to PB9. I don't understand why now the id of t_stock is not passing into this clicked() event.
Here is the code for the "clicked( integer xpos, integer ypos, long row, dwobject dwo)" event script of the ancestor uo_dw:
/*
** Used to make sure that the row gets set even if they click on a column
** with a tab order of 0
*/
string tab,ls_clickedcolumnID
SetPointer(HourGlass!)
/*
** Set row focus even if tab order = 0.
** Return if click was not on a valid dwobject, depending on what was
** clicked, dwo will be null or dwo.name will be "datawindow"
*/
If IsNull(dwo) OR dwo.name = "datawindow" Then Return
//If IsNull(dwo) Then Return
//If dwo.name = "datawindow" Then Return
//Find which column was clicked on and return if it is not valid
If ClassName(dwo.id) <> 'string' Then Return // FAILS HERE
ls_clickedcolumnID = dwo.id
If ls_clickedcolumnID = '' Then Return
If row <> this.GetRow() then
tab = Describe('#'+ls_clickedcol
If tab = '0' Then this.SetRow(row)
End If
/*
** Bring this datawindow control into focus on top of all others.
*/
this.BringToTop=True
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
YES!! That's why. That allowed me to fix the problem. I did a messagebox on dow.type and found it not to be a button, but raised text. It looked like a button, but it was raised text. When you said "dwo.id can be used only for columns and not buttons", it made me realize I need to check the dwo.type, not dwo.id. It kept blowing up when I did "If isNull(dwo.id)". It could find the reference of something that it couldn't even check to see if it was null.
Your answer, Rosh, is what triggered my brain to realize what I needed to do. I've got many years of C programming, but still learning the OO world.
THANKS!!!
Your answer, Rosh, is what triggered my brain to realize what I needed to do. I've got many years of C programming, but still learning the OO world.
THANKS!!!
thanx for the grade and points...
Glad tio give that extra push buddy ;)
Cheers,
Rosh
Glad tio give that extra push buddy ;)
Cheers,
Rosh
can u paste the code in ur clicked event so i can point the error...
its basically an error in code
ur referencing an object which does not exist...
so check line 22 and check the dwo.id... see if it exists... also check if ur using any dot object notation and is it right....
also try using dwo.name instead...
Do let me know for more assistance.... paste the code so that i can help to pin point the error in code...
Cheers,
Rosh