Board index » delphi » Please Give Advice for One to Many Relationship Concept

Please Give Advice for One to Many Relationship Concept

Can someone please help me with this problem?

I am constructing a database for my business (Delphi Style of course) and need
some advice with logic.  The Paradox Tables I have contructed are:

Customers
Service     (profile of the services my business offers)
Invoices
Profile     (profile of the customers totals, balance due, etc..)

They all have a topmost field called "CustNum" of  Long Integer type.

I have so far created (with Delphi's Database Expert) a linked relationship form
(Customer.DB  and  Service.DB) with the CustNum field, to add, edit, delete, etc.
records from the Customer.DB and Service.DB.

This works fine..  I have also created a form for making new Invoices. Currently
it just contains one table and a datasource.

What I can't understand is how when in the Invoice form, (currently just containing 1
datasource for the Invoice database) do I design it so that when I enter the Customer's
ID in the CUSTID field, (of the Invoice.DB)  the Company Name will appear in the
Invoice.Company field automatically ??? (or address, or any other info I might want
on that form)

Also: How could I keep the Invoice Table in Sync with the Customer Table at all times..?
In other words,..  If I choose a customer from the customer table, and then select a
menu or button command (not in place yet) to "Create a new Invoice", will the invoice
form already have the customer information in place, needing only to fill in the
information specific to that invoice?

 

Re:Please Give Advice for One to Many Relationship Concept


I think that usual statement is:

procedure TForm1.InvoicesCalcFields(DataSet: TDataSet);
begin
  if Customers.FindKey([InvoicesCustID]) then
  InvoicesCompany.Value := CustomersCompany.Value;
end;

But in data entry if you want immediatly appearence of Company
after entering a CustID you can put the same in DBEditCustID.OnChange
for example.

Nenad

Other Threads