criteria for views

criteria for views

Each of the users of my application belongs to a given firm, and each firm can have several users.
The association between firm and users is established in a form, called Users, with fields : FirmCode, UserEmail. The UserEmail is the same as the zoho.loginuserid.

I now wish to construct a View on another form, called Orders, such that all users of a given firm can see only the orders of that firm, irrespective of which user of that firm has placed them. In the Orders table I have a "FirmCode" field but I do not know how to set a criterion in the Orders view since I would have first to fetch the firm code the logged in user belongs to from the Users table and then have the view to

show all rows from Orders[FirmCode == FirmCodeOfGivenUser]

I know how to write the code in order to fetch the firm code from Users but can I and if so where should I place it in the View code of Orders ? Many thanks.