Actually, you try in two ways :
1. If form A contains the same data with form B, try to make form A as inheritance form of form B.
2. Try using Lotusscript instead of Formula. LotusScript can handle more complex programming logic than Formula. You can get some references in searching method through Lotus Domino Designer Help.
Wish you luck