Hi all,
In my main app I have a "Navigator". The user double-clicks on a window name to open it. One of the windows is "Status Tracking".
In some windows, the user can double-click on a particular dw row to open another window. If I double-click from say, the Lab Folder, the Lab Folder opens Status Tracking and sends in a PowerObjectParm consisting of several arrays. Status Tracking checks for a PowerObjectParm, and if it's not null it processes accordingly (basically automatic retrieve). If a PowerObjectParm is not passed in, Status Tracking should open in Query mode.
This is working fine when when I open Status Tracking from other windows. But, when I open Status Tracking from the navigator (ie, no PowerObjectParm sent in) I'm getting a Null Object Reference, line 23 of pfc_postopen event.
Here's how I open Status Tracking from the Lab Folder:
istr_parms.long_arg[1] = ll_salesorder istr_parms.long_arg[2] = ll_workorder istr_parms.string_arg[1] = "WO" OpenSheetWIthParm(lw_sheet, istr_parms, "w_md_status_tracking", w_benchtop_frame, 0, Layered!)
Here's the Status Tracking pfc_postopen event :
// Save parameters that may have been sent in if NOT IsNull(Message.PowerObjectParm) then istr_parms = Message.PowerobjectParm is_retrieval_type = istr_parms.string_arg[1] il_salesorder = istr_parms.long_arg[1] if UpperBound(istr_parms.long_arg) > 1 then il_workorder = istr_parms.long_arg[2] end if dw_1.Retrieve(il_salesorder) if is_retrieval_type ="WO" then rb_workorder.Checked = TRUE //Scroll to the workorder that was sent in // Find this workorder in the list... ls_find = string( il_workorder ) ll_ThisRow = dw_2.inv_find.of_find( "id", ls_find, 1, dw_2.RowCount() ) if ll_ThisRow > 0 then dw_2.ScrollToRow( ll_ThisRow ) dw_2.SelectRow( 0, False ) dw_2.SelectRow( ll_ThisRow, True ) end if end if end if
I'm getting a NULL Object Reference line 23 (is_retrieval_type) when I open Status Tracking from the Navigator. The Message.PowerObjectParm should be null as I opened the window without any parameters and this whole IF clause should be skipped. Maybe the Message.PowerObjectParm is not Null and is a hangover from previous calls? In the debugger, istr_parms isn't even the right structure. How can I check to see if the PowerObjectParm is of the class/type str_parms?
~~~Tracy
Another good point from John's code example ... Only use the ISVALID () command to test for valid object pointers. The IsNull() command you mentioned in your initial post is *not* for pointer validation. It's designed for testing data values of type NULL. You can have a non-null object pointer but in reality, that positive memory address may no longer be valid. So the Isnull() would be FALSE making your code "think" that the object pointer was OK whereas in reality it might not be. The IsValid() command though will verify the memory address properly. Food for thought. HTH
Regards .. Chris
I learn something new every day! Thanks, guys!