In regards to your tool, there is a few things you need to do:
1. Make you button a toolbutton for it to react to you clicking in the map
A toolbutton can also be given a drawmode, in your case DM_CUSTOM_POINT which makes the tool react to a single click, and a cursor, use MI_CURSOR_CROSS for a crosshair. Both these two defines can be found in the Menu.def file that you need to include in your code.
2. Select records nearby your click
Secondly, you need to find the records nearby the point where you clicked in the map.
These requires that you initially get the coordinate of the point where you clicked:
Dim fX, fY As Float
'**Let's use the coordinate system of the active Map window
Set CoordSys Window FrontWindow()
fX = CommandInfo(CMD_INFO_X)
fY = CommandInfo(CMD_INFO_Y)
Now your variables fX and fY hold the coordinate where you clicked. Let's find the records nearby.
Dim oBuffer As Object
'**We are adding a search area around the point using a buffer
'**If you data is projected, you can also use CartesianBuffer
'**20 is the resolution of the buffer and 5 is the search distance
oBuffer = Buffer((CreatePoint(fX, fY), 20, 5, "m")
'**Let's select the records nearby - here I'm selecting from the table LINK
Select * From LINK
Where OBJ Intersects oBuffer
Now you have you objects selected and you can continue with your code from the question above.