Grid link to another grid

I have a grid and I want to link to another grid to display the details.

I try create a new HTML image field and link to my details grid.
On ‘OnRecord’ event I set [glo_var] = {local_var} and already set to OUT.

At details grid, at SQL statement I have added where local_var = [glo_var]

Here’s the problem comes out. When I click on the new field I just created. It did direct me to details grid but it always show me the last record of the page.

Anyone help is appreciated!

The onrecord event is triggered at every displayed record, so the latest situation of [glo_var] will be your last record of the current page.
In general, if you create a link you need to link to the matching sql. So your detail page should have something like where mykey=’[glo_var]’ Then when you create a link to this detail page you will get a form where you can bind this variable to your current keyvalue. It’s in the dropdown. Then the application should work fine. No need to use event code.