How do you search a Linking Module?

How do you search a Linking Module?

I have a custom module (CustomModule6) that has a multi-select field related to Vendors. There is a linking module (LinkingModule2).

For a particular record in the custom module, how to I get the IDs for the selected Vendors? (using a custom function where the input is CustomModule6 ID)

I've spent a few hours at this already trying all sorts of things without success, so a nudge in the right direction would be appreciated.