Hi guys,

I was hoping somebody could kindly shed some light on a relatively basic function for I am trying to execute in Delphi for a project I am completing for work. I am very new to the world of Delphi so any assistance would be greatly appreciated.

I have connected a MS Access Database to some DBLookupComboBoxes. A one to many relationship exists whereby a user selects a particular material from a dropdown menu, but for each material, there may be more than one colour that the user can select, all of which price may differ.

Currently, if a user selects a particular material, all the colours within the database display, irrespective of material chosen. In addition, depending on the material that is selected, all the colours are highlighted by the pointer for when the user attempts to chose a colour.

I eagerly anticipate any reponse from the professionals!!

I advice you to try and use a normal comboBox instead of a LookupComboBox,

Step One :

On OnCreate of the form populate the comboBox with material Description from the table using a for-loop :e,g

for K := 0 to tblMaterial.RecordCound - 1 do
begin

comboBox1.Text.Append(tblMaterialDescription.Value);
tblMaterial.Next;
end;

Then you filter the Child-table with the description in the comboBox using the OnChenge event of a comboBox : e.g
begin
tblColor.Active := true;
tblColor.filtered := true;
tblColor.filter := 'Material_Description =' + QuotedStr(comboBox1.Text);

end;


I hope this will solve you problem.

I advice you to try and use a normal comboBox instead of a LookupComboBox,

Step One :

On OnCreate of the form populate the comboBox with material Description from the table using a for-loop :e,g

for K := 0 to tblMaterial.RecordCound - 1 do
begin

comboBox1.Text.Append(tblMaterialDescription.Value);
tblMaterial.Next;
end;

Then you filter the Child-table with the description in the comboBox using the OnChenge event of a comboBox : e.g
begin
tblColor.Active := true;
tblColor.filtered := true;
tblColor.filter := 'Material_Description =' + QuotedStr(comboBox1.Text);

end;


I hope this will solve you problem.

I advice you to try and use a normal comboBox instead of a LookupComboBox,

Step One :

On OnCreate of the form populate the comboBox with material Description from the table using a for-loop :e,g

for K := 0 to tblMaterial.RecordCound - 1 do
begin

comboBox1.Text.Append(tblMaterialDescription.Value);
tblMaterial.Next;
end;

Then you filter the Child-table with the description in the comboBox using the OnChenge event of a comboBox : e.g
begin
tblColor.Active := true;
tblColor.filtered := true;
tblColor.filter := 'Material_Description =' + QuotedStr(comboBox1.Text);

end;


I hope this will solve you problem.

Hi Motapa,

Thank you SO very much for your assistance. I somewhat understand what you are saying but would it be at all possible for you to forward some kinof working example of this idea which is attached to an Access database? The demonstration of two comboboxes working together would surely be appreciated as I have to a multitude of options to link. I will then be able to apply the same logic throughout the program.

Again, I sincerely thank you for your time and assistance.

Kindest Regards

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.