Change filter subpanel based on custom field

I’m looking for assistance on the following. Lets say I have Accounts module and the Contacts Module. Contacts has a sub panel within Accounts that is linked via the contact being a member of the respective account by default. I want the sub panel for contacts with an account to be linked via a custom field such as “Field A” (both modules have a custom field that could contain the same data), so that when I am in an Account, the subpanel for Contacts shows all contacts that have the same value for that customer field. Where is the query that drives the sub panel currently? Where can I quickly change it to be related based on another field? Any assistance would be greatly appreciated!

Take a look into this post for some ideas: