title: Salesforce: Cannot update lookup field value with trigger
body: <p>I'm just trying to update a lookup field value (Campagna_Account__c) on Account object using a trigger that should update it getting the value from a custom object (Sottocampagna__c).
  I think the query is right because it runs well on Force.com Explorer, so I think the problem is somewhere else.</p>
  
  <p>Here's the error line displayed when trigger fires: </p>
  
  <blockquote>
    <p>data changed by trigger for field Campagna: id value of incorrect
    type: a06250000004FDNAA2</p>
  </blockquote>
  
  <p>Here's my code:</p>
  
  <pre><code>trigger PopolaCampagna on Account (before insert, before update) {
  
      Sottocampagna__c var = [
  
          SELECT Campagna__r.Id 
          FROM Sottocampagna__c
          WHERE Name='Segugio'
  
          ];
  
  for (Account a: Trigger.new) {
  
          a.Campagna_Account__c = var.Id;
      }    
  }
  </code></pre>
  
  <p>Thank you for helping me!</p>