I haven't touched Delphi in years, but I'd assume that
if sStudent <> ' '
will execute everything inside the
if
block
unless the textbox contains a single space. So if you leave it empty, or type in anything other than a single space, the message will be shown.
You probably also want to move the
LoadFromFile
line into an
else
block, and you might need to remove the leading space from the file name, depending on how you've named the files.
sStudent := EdtSearch.Text;
if sStudent = ''
then
begin
Application.MessageBox('No data has been inputed. Please Input a name to search', 'Error no information to search', 0);
end
else
begin
RDisp.Lines.LoadFromFile('Students\' + sStudent + '.txt');
end;