Thank you joseme for your response.
BigChimp, I don't have internet access...so this response is getting back to you sort of after the fact. After I posted my issue yesterday, I went back home and kept working with it. In the DB Tutorial 2 I recalled the use of Params and ParamByField. And, as it turned out, the first shot at it with my DBLookupComboBox.Text was all I needed. Here's my working result:
procedure TForm1.alLoadCustomerExecute(Sender: TObject);
begin
// This loads the DBLookupComboBox
with IBC1 do
begin
DatabaseName:= 'Jericho';
HostName:= 'localhost';
Password:= 'masterkey';
UserName:= 'sysdba';
Transaction:= SQLT1;
end;
with dblcbCustomerName do
begin
Datasource:= DS1;
DataField:= 'NAME'; // Not sure if all three of these
KeyField:= 'NAME'; // '.Field' calls are necessary.
ListField:= 'NAME'; // Best to err on the side of caution.
ListSource:= DS1;
Sorted:= True;
end;
// Use the Customer Name from CUSTOMER Table, loaded in dblcbCustomerName.Text,
// to load, by Customer Name, customer info from LOCATIONS Table.
SQLQ2.Close;
SQLQ2.SQL.Text:= 'select * from locations where customer_name = :' + dblcbCustomerName.Text;
SQLQ2.Params.ParamByName(dblcbCustomerName.Text).AsString:= dblcbCustomerName.Text;
SQLQ2.Open;
// Hide the primary key column which is the first column in our queries.
// We can only do this once the DBGrid has created the columns.
SQLQ2.FieldByName('LOC_ID').Required:= False;
DBGrid1.Columns[0].Visible:=false;
end;
This works.
However, it seems I have to use two connections, two transactions, two queries, and two datasources because I use two tables. Is this the only way to do it? Two of everything to access two tables of the same .fdb? Delphi uses a Table component to work with multiple tables, right?
Also, I have a DBNavigator set to the DBLookupComboBox and a DBNavigator set to my DBGrid. Thing is, I can't make changes. I can't add, delete, edit. Nothing. I've gone back and looked at the Tutorial 2 code but can't see anything different from what I'm doing. I connected it and thought that was all I had to do. Is there more? And, as you can see in my code, I have the LOC_ID set to not required when adding a record, but when I do this via the Navigator I get an error saying that it's required but not provided. Please point me in the right direction. Thank you for your help and patience.
Landslyde