Introduction
I have a form with a TComboBox
that I want to populate with a field from a table in my database using a query. I also want the values in the field displayed in proper case, which can be achieved using Access’ StrConv
function. Here’s my code:
with dmCallNote.qryCompany, SQL do
begin
Clear;
Text := 'SELECT StrConv(A_Company, 3) FROM tblAccounts';
Open;
while not Eof do
begin
cmbCompany.Items.Add(dmCallNotes.qryCompany['A_Company']);
Next;
end;
end;
The Problem
When compiling the line cmdCompany.Items.Add …
I receive the error message:
“qryCompany: Field 'A_Company' not found.”
Why am I getting this error? When I run the query with a TDBGrid
it executes successfully.