title: Running a query and displaying result it in a TEdit
body: <p>I have a <code>TComboBox</code> containing a list of names gathered from my database. Next to it is a <code>TEdit</code> that I intend on using for the purposes for displaying the ID number associated to each person. </p>
  
  <p>Since firstName and lastName are separate fields within the table, but displayed together in the TCombobox I have written a small section to split the firstName and lastName into two separate variables:</p>
  
  <blockquote>
  <pre><code> pos := AnsiPos(' ', cbStudents.Text); 
   firstName := Copy(cbStudents.Text, 0, pos-1);
   lastName := Copy(cbStudents.Text, pos+1, Length(cbStudents.Text));
  </code></pre>
  </blockquote>
  
  <p>Then I execute the SQL code:</p>
  
  <pre><code>  try
      query.Open;
      query.SQL.Add('Select studentID');
      query.SQL.Add('From student');
      query.SQL.Add('Where firstName = ' + StrToQuote(firstName));
      query.SQL.Add('And lastName = ' + StrToQuote(lastName));
      editID.Text := query
    finally
      query.Free;
    end;
  </code></pre>
  
  <p>Note: <code>StrToQuote</code> encapsulates the variable firstName and lastName with double quotes (" ")</p>
  
  <p>The error that I am receiving is:</p>
  
  <p>Argument out of range</p>
  
  <p>What am I doing wrong? Thank you in advanced for the help.</p>