Question: I have a created one Field on contact which is having checkbox data type name as "In use".
I have a requirement like

1.One Contact can only be active at one place at a time. So we want to restrict the "In Use" field from being active if it is currently active on another Contact for the same account.

Answer: 
I hope this would be helpful... 

```
   trigger validate on Contact(before insert){

        set<id> rids = new set<id>();
        set<id> Uids = new set<id>();

        for(contact c : trigger.new){
              rids.add(c.AccountId);
        }
        list<contact> conts = [select accountid from contact where accountid IN :rids AND In_Use__c = true];
        for(contact c : conts){
           uids.add(c.accountid);
        }

        for(contact c : trigger.new){
             if(uids.contains(c.AccountId)){
                   c.addError('Account Related contact is already in Use');    
             }   

        } 
}

```
Here is an option to fill the requirement without using code:  

1. Create a unique field in contact.  

2. Create a workflow on creation/update of contact when the in use check box is checked that fills the unique field created in section 1 with the account id.  

3. Create a workflow on creation/update of contact when the in use check box is un-checked that clears the unique field created in section 1.  

This way, when someone will try to check the in use check box under the same account he will get notification that there's a duplication and referral to the in use contact.