I have a `TComboBox` containing a list of names gathered from my database. Next to it is a `TEdit` that I intend on using for the purposes for displaying the ID number associated to each person. 

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:

> 
> 
> ```
>  pos := AnsiPos(' ', cbStudents.Text); 
>  firstName := Copy(cbStudents.Text, 0, pos-1);
>  lastName := Copy(cbStudents.Text, pos+1, Length(cbStudents.Text));
> 
> ```
> 
> 

Then I execute the SQL 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;

```

Note: `StrToQuote` encapsulates the variable firstName and lastName with double quotes (" ")

The error that I am receiving is:

Argument out of range

What am I doing wrong? Thank you in advanced for the help.