Board index » delphi » LookupCombobox

LookupCombobox


2004-07-14 08:25:46 PM
delphi95
Hi,
i would like to achieve Master-Detail relationship via two ibdataset.Their
SelectSQL are something like
IBDataset1 : Select * From Personel
IBDataset2 : Select * From Order where Order.Personelid= :Selectedid;
By using a lookupcombobox i am populating its content with ibdataset1.Then
selecting a personel form comobox.My Question is how can i able to set
"Selectedid" parameter with the value from combobox's lookup parameter?
Regards
FEZA
 
 

Re:LookupCombobox

"Bill Todd (TeamB)" <XXXX@XXXXX.COM>, haber iletisinde sunlari
yazdi:XXXX@XXXXX.COM...
Quote
Make the parameter name the same as the field name in the parent table
then set the child IBDataSet's DataSource property to a DataSource
that is connected to the parent IBDataSet property. When you do this
the parameter will be set automatically.
Hi Bill,
i do not want it to be automatic.Because I'd like to restrict records by
a dbcombobox upon user choose.DbCombobox populated with master IBDataset.
 

Re:LookupCombobox

Quote
And that is exactly what you will get if you do as I said. Each time
you choose a new record in the master table the detail IBDataSet will
fetch the detail records for that master record.

Ok ,Where do you think, i can set Datasource and Datafield property of
DBCombobox?
Thank you
FEZA
 

Re:LookupCombobox

Quote
I do not understand why you are using a DBComboBox component. A
DBComboBox does not display data from a dataset. Instead it displays
the static list entered into its Items property so you can select one
of the items and assign its value to a field in a dataset.

Perhaps I do not understand what you are trying to do. As I understand
it you have a master table and a detail table. Let's user Customers
and Orders as an example. You want to display some of the rows from
Customers and let the user select one. When the user selects a
Customer row you want to display the orders for that customer.

The way I'd do that is to use two DBGrids. If you want to use a
ComboBox use TComboBox, not TDBComboBox, and write code to load the
field values from the Customers dataset into the ComboBox.Items
property. Then write an OnClick event handler for the ComboBox that
sets the parameter value for the Orders IBDataSet and opens it.
That's absolutely What i am trying to do.First, i am looding TCombobox with
Customer information and let the user make choice on Customer name, then
wite OnClick event of TComboBox.However, i need to know Customerid in order
to set for IBDataset parameter.Look at below please
Customer SelectSQL:
Select * From Order Where Order.Customerid = :Choosenid
I can use Locate method maybe, But i have heard , there is performans
penalty in using this method? Maybe You can mke some suggestion....
procedure TMyProject.ComboBox1Click(Sender: TObject);
begin
Modul.TrnCustomer.Commit;
with Modul Do Begin
TrnCustomer.StartTransaction;
tblCustomer.ParamByName('Choosenid').AsInteger := //need to set a value
Bill
tblsokak.Open;
end;
end;
Many many Thanks to you Bill
FEZA
 

Re:LookupCombobox

Thank you for your explanation Bill
Best Regards
FEZA
Quote
The ComboBox must contain the primary key or another value that
uniquely identifies the record. If it contains a value other than the
primary key you would get the primary key by executing a SELECT
statement similare to the following.

SELECT CUSTOMER_ID FROM CUSTOMERS
WHERE OTHERKEY = :OTHER_KEY_VALUE

Do not use Locate or any other client side search function with a SQL
database server. The fastest way to find something is with a SELECT
statement.
 

Re:LookupCombobox

Quote
The ComboBox must contain the primary key or another value that
uniquely identifies the record. If it contains a value other than the
primary key you would get the primary key by executing a SELECT
statement similare to the following.

SELECT CUSTOMER_ID FROM CUSTOMERS
WHERE OTHERKEY = :OTHER_KEY_VALUE

Do not use Locate or any other client side search function with a SQL
database server. The fastest way to find something is with a SELECT
statement.
Everthing is seems perfect.i would like to ask my last question.Althought i
change Order ChoosenField parameter , it does'nt update its view according
to customer id.
Select * From Order Where Order.Customerid = :Choosenid
procedure TMyProject.ComboBox1Click(Sender: TObject);
begin
tblOrder.ParamByName('ChoosenField').AsInteger := NewValue;
end;
if i commit active transaction then open order table again, everthing works
perfect.But In this case, i can't give the user chance to commit or
rollback.Can you please guide me?
Regards
FEZA