Know a id of a selected record in a grid

Hi everyone

I have to put in two different global, the id and another value of a field present in the same record displayed in a grid
The grid has a button to switch to an application form where the global two must arrive
The problem is that I always get the values of the last record and not the one selected by pressing the button
Tips?
Thank’s
Mimmo

show your code

Thank’s but solved

share solution for future use plz