AgTalk Home
AgTalk Home
Search Forums | Classifieds (74) | Skins | Language
You are logged in as a guest. ( logon | register )

Microsoft Access
View previous thread :: View next thread
   Forums List -> Computer TalkMessage format
 
CentralNEFarmer
Posted 6/4/2008 15:41 (#390523 - in reply to #390375)
Subject: RE: Microsoft Access



Custer County, Nebraska

First as a caveat, I haven't used Access to any great extent, and the time I have is approaching a decade ago. My experience is more along the lines of accessing and manipulating data programmatically and via stored procedures.

Ok if I understand you correctly, here is how I would approach this problem.

You are going to need 3 tables.

First table will be tblEmployee, containing your employee information such as Name, Address, Phone... and most importantly an EmployeeID field. The Employee field is your Primary Key utilizing a unique number.

Second table will be tblLocation, containing data such as FieldOffice, FieldDivision, FieldPhone, and the Primary Key LocationID, once again filled with a unique number.

The third table will be an combination of the Primary Keys of both tblEmployee and tblLocation. Call this table tblEmployeeLocations. You will have two foreign key fields, a EmployeeID and LocationID. I would suggest that you make these two fields, together, as the Primary key for this table to prevent dublicate entries.


A crude diagram

------------------
| tblEmployee    |
|----------------|
|EmployeeID      |
|Name            |
|Address         |
|Phone           |
------------------

----------------
| tblLocations |
|--------------|
| LocationID   |
| FieldOffice  |
| FieldDivision|
| FieldPhone   |
----------------

------------------------
| tblEmployeeLocations |
|----------------------|
| EmployeeID           |
| LocationID           |
------------------------

Now we can assume some data.

Employees
Name - ID#
-----------
John - 1
Frank - 2
Bill - 3


Locations
Name - ID#
-------------------------
Grain Elevator - 1
Sales - 2
Commercial Applicator - 3



Assume John works in both the Grain Elevator and is a Commercial Applicator, Frank Works in Sales,

and Bill works in all three locations

Enter into tblEmployeeLocations
EmployeeID - LocationID
-----------------------
1 - 1
1 - 3
2 - 2
3 - 1
3 - 2
3 - 3



To generate a report, I would then create a SQL query using an Inner Join.

SELECT tblEmployeeLocations.EmpID, 
       tblEmployeeLocations.LocID,
       tblLocations.LocationID,
       tblLocations.LocationName,
       tblEmployees.EmployeeID,
       tblEmployees.EmployeeName

FROM tblEmployeeLocations
     INNER JOIN tblLocations ON tblEmployeeLocations.LocID = tblLocations.LocationID 
     INNER JOIN tblEmployees ON tblEmployeeLocations.EmpID = tblEmployees.EmployeeID

ORDER BY tblLocations.LocationName


Now this may not be exactly the way to approach things in Access, but I hope it a least points you in the right direction.  Good luck.

Top of the page Bottom of the page


Jump to forum :
Search this forum
Printer friendly version
E-mail a link to this thread

(Delete cookies)