Fetching values error/problem

Fetching values error/problem

I have two forms set up. They are "Applicant" and "Enquiry".


Applicant form has some fields like "Name", "Email" etc.


In the Enquiry form, I have inserted a lookup field (theName) and have set that to lookup "Name" as dropdown from "Applicant". I have added another field "test" to this form.


Now in Field Action>Name>On user input, I have entered the following code:
  1. if (input.theName != null)
  2. {
  3. data = Applicant [ID == input.theName];
  4. input.test = data.Email;
  5. }


On saving the script, I am getting this error: 

Improper Statements/Expressions found 

java.lang.NullPointerException



What am I doing wrong and how do I correct it? The applicant for has 2-3 entries for testing purpose.