Topic: Foreign Key

I wanted to use combo box for dictionary tables but stuck with foreign key settings on object inspector. Could somebody please explain how to use it? On tutorial video 2, I see there is a "table name" instead of "foreign key".

Adam
God... please help me become the person my dog thinks I am.

Re: Foreign Key

Hello AD1408

Foreign keys (using only with comboboxes) are ways to use fields coming from a table and use them in another table.
Let me explain :

I want to write an application managing Rental technicals equipments.
For this, I have create three tables:
A Table Rent (the main table - Table A), a table Customer (Table B) and a table Equipment (Table B).
To manage my locations, I need to know which client (B) borrows what kind of materials (C).
In my main table (Rent), I have to declare that tables Client and Equipment have a relationship with the Rent Table (B and C are connected with A).
The declaration is made after creation of 3 tables and it is from Table A that I will declare the relationships B and C (via New field and RelationShip).
Those new links B and C towards A are called Foreign Keys.
Foreign Keys are only tables as A but the name indicates they have a relationship with a third and main table.

See example to have an idea about foreign keys.

An now how with comboboxes ?

Let's say you've declare table Client with 2 fields : Name and Telephone.
Let's say you've declared table Equipment with two fields : Tech and CostPerDay.

Well ! when you place a combobox for client, as Foreign Key you'll déclare Rent.id_Client and FieldName : Name
and when you place a combobox for technology, as Foreign Key you'll déclare Ren.id_Equipment and as FiedlName : Tech.
When you run your projet, you will be able to choose you client and your tech.

Of course, you will have to set the grid which will display your searches.

And last, if you use an SQL Query, there is a special syntaxe to call foreign Key.
We're not there yet but we are there to help you about thi

Does that answer your question ?

JB

Post's attachments

Attachment icon example.jpg 29.68 kb, 281 downloads since 2016-08-14 

Re: Foreign Key

Hi JB.

Thanks a lot for your kind explanation together with image. It's appreciated very much...........

Adam
God... please help me become the person my dog thinks I am.