Hi Leon,
First of all, I would suggest you to use Item_Pressed Event on BeforeAction == false instead of Click, if you are using.
The error you are getting because no row is selected, still your code executes. Better if you can check the values first, on the row that has been clicked.
Kind regards,
ANKIT CHAUHAN
SAP Business One Global Support