You can use IsLoaded function to determine wich form is loaded, if it is form(b) then do this do that, elseif it is form(a) then do this do that.
If for instance you have the both (form(a) and form(b) open, you can't use the function. Instead, declare public variables to have the value of 0 and 1. When you click in form(b) to open form(c) the variable frmB=1 and frmA=0.
In the OnOpen event of form(c), if frmB=1 and frmA=0 then .... Elseif frmB=0 and frmA=1 then.... ElseIf frmA=0 and frmB=0 then.....
When closing the form(c) reset the values to Zero of the two variables.