Reputation: 11
I have been stuck with this error after trying everything i have learned. I have two DBGrids on my form and they both have different names and are connected to two different ADO connections. When I filter the database I get the error as stated in the title, I have no idea what to do, this is how that part of my program looks.
procedure TfrmDatabase.btnYouTubeSearchClick(Sender: TObject);
var
sName: string;
begin
sName := InputBox('Enter the name of the YouTuber you want to search',
'Please enter name here', '');
with DataModule3 do
begin
tblYouTube.Open;
tblYouTube.Filtered := false;
tblYouTube.Filter := 'Name of YouTuber = ' + QuotedStr(sName);
tblYouTube.Filtered := true;
end;
end;
Upvotes: 1
Views: 2210
Reputation: 7289
When using dbGO ADO connections field names with spaces need to be surrounded by brackets. It also needs to be the field name for the table and not the field title / caption so double check that.
tblYouTube.Filter := '[Name of YouTuber] = ' + QuotedStr(sName);
From the help: Data.Win.ADODB.TCustomADODataSet.Filter
When a field name contains spaces, you must enclose the field name in brackets. For example:
[Home State] = 'CA' or [Home State] = 'MA'
Upvotes: 2