Open a Window by clicking a record in another DataWindow

3.4k Views Asked by At

I have a DataWindow which gets the records using select.

What I want to do is to be able to click on any record and open a new Window/DataWindow to display more information about that selected/clicked record.

I am fairly new to PB8 and struggling at the moment with this.

Can you please guide me in the right direction, will really appreciate it.

Cheers.

2

There are 2 best solutions below

0
On

You want to look at OpenWithParm() or OpenSheetWithParm(), and calling one of those from the Clicked event (I'd recommend DoubleClicked, but it's your design) of the DataWindow control (on the window).

You might also want to look at the Getting Started Manual, which comes on the disk and is also available online.

Good luck,

Terry.

0
On

It sounds like you are pretty new to PB so I'll give you a really simple sample to get you started. Might consider doubleclicked as Terry suggested but clicked will work too.

Assumptions:

  • Your datawindow control name is dw_customer_list
  • Your column value (key) is named customer_id and is numeric
  • Your window name to open is named w_customer_detail
  • The value you are passing is a number otherwise use StringParm or PowerObjectParm
  • If you are using mdi "sheets" then consider opensheetwithparm instead of openwithparm

In your clicked event of the dw_customer_list add code to grab the key value for whatever you want to display on the window you are opening. If you use a string then use getitemstring instead of getitemnumber

double ld_custid

if IsNull(row) then return 0

if row > 0 and row <= RowCount() then
   ld_custid= this.GetItemNumber(row, 'customer_id')
   OpenWithParm(w_customer, ld_custid)
end if

And in your w_customer_detail for which you want to display the customer put something like this in the open event to grab the passed parameter and do something with it. Some other day when you're bored read about the postopen event and why it is good to use. Also if you were passing a string instead of a number then just use Message.StringParm instead of DoubleParm.

double ld_custid

// grab the passed number parameter
if not IsNull(message.DoubleParm) then
   ld_custid= message.DoubleParm
   messagebox('Customer ID parameter:', string(ld_custid))
else
   // no parmameter!
   messagebox('Customer ID parameter:', 'was not passed to window')
end if