View Single Post
  #7  
Old November 8th, 2008, 08:16 PM posted to microsoft.public.access.gettingstarted
Wayne-I-M
external usenet poster
 
Posts: 3,674
Default Multiple Records

Sorry don't have much time - saturday night and all that :-)

Anyway I asusme that you have created the tables ?

Open the relationship window and link the companies table with the directors
table (using the CompanyID)

The best next step would be to use a query with a subquery to give the the
diectors of each company the correct company ID (which you need to like the
tables - and this will enable your form to work as you want it.
Check out Allans Brown's site for the best way to create query/subs

But for now we will do it with 4 queries - 2 totals query and 2 append
querries

They MUST be run in the right order or they will not work (as you can not
give a likning field to the directors until each company as a primary field)

So create four queries

qryCompaniesTotal
qryDirectorsTotal
qryDirectorsAppends
qryCompaniesAppend

I assume you have used the field names I gave. If not them give it a try
with those names and them change them later (just so you can ee who it works)

Open each of the queries in design view and select Veiw - SQL
Paste this into each qry and then save an close (without running)


qryCompaniesTotal

SELECT tblMyExcelStuff.[Company Name], tblMyExcelStuff.Incorporation,
tblMyExcelStuff.DateOfIncorperation
FROM tblMyExcelStuff
GROUP BY tblMyExcelStuff.[Company Name], tblMyExcelStuff.Incorporation,
tblMyExcelStuff.DateOfIncorperation;


qryDirectorsTotal

SELECT tblMyExcelStuff.[Company Name], tblMyExcelStuff.DirectorsLastName,
tblMyExcelStuff.DirectorsFirstName, tblCompanies.CompanyID
FROM tblCompanies RIGHT JOIN tblMyExcelStuff ON tblCompanies.[Company Name]
= tblMyExcelStuff.[Company Name];


qryDirectorsAppend

INSERT INTO tblDirectors ( DirectorsLastName, DirectorsFirstName, CompanyID )
SELECT qryDirectorsTotal.DirectorsLastName,
qryDirectorsTotal.DirectorsFirstName, qryDirectorsTotal.CompanyID
FROM qryDirectorsTotal;

qryCompaniesAppend

INSERT INTO tblCompanies ( [Company Name], Incorporation,
DateOfIncorperation )
SELECT qryCompaniesTotal.[Company Name], qryCompaniesTotal.Incorporation,
qryCompaniesTotal.DateOfIncorperation
FROM qryCompaniesTotal;


OK - if all that is doen.

Next open the tables Directors and companies and make sure they are empty -
delete all records

Next click
qryCompaniesAppend
Select yes to update

Click
qryDirectorsAppend
SelectYes to update

Now your form should work

I hope :-)





--
Wayne
Manchester, England.



"pupkiss1965" wrote:

I have created all the tables as you suggested. I now have a table for each
of the columns that were brought over from excel spreadsheet. SDC is just a
file number and shareholders I called it tblShareholders.