Need a simple database....but not sure how to start

G

Guest

Good morning,
I am sort of new to access, I understand the basic but I am having problems
getting started with my database. I am the office mangement for our safety
dept and I need a databse that keeps track of all employees who has had an
accident( of any type), how many in that department, and to keep a record of
how many points that each employee have accumalative that drives a county
vehicle.
This is what I have so far:

tbl employee Incident
employeeID
name, address, city, zipcode
department (combox)
jobtitle
location of accident
date injury
time work began
date employer notified
type of injury/accident
what part of body affected(combox)
points
summary
hospital/physician, address, telephone
no treatment (yes/no)
minor: by employer (yes/no)
minor: by hopsital/clinic (yes/no)
emergency care (yes/no)
hospitalized>24hrs (yes/no)
report prepared by
position
telephone date of report

tbl total injuries
employeeID
totEmp
totDept
totpts

My problem is that I am not sure on how to relation the field so for I have
tbl empIncident to tbl total injuries as a one to many.
For my total I have them in the group footer count(employeeId) for totemp,
count(points) for totpts and for department I have Count(codepartmentID) that
does not work the way I need it to work, I need for it to count all the
accident that has happen in the road dept vs all of them.

any ideas and help is appreciate thanks
 
E

Ed Warren

First try putting all into simple English.
Each Department can have 0 to many Employees
Employees have accidents
Accidents come in types of accident
each employee can have zero to many accidents
Each Accident can have one and only one AccidentType
Each AccidentType can have 0 to many Accidents

Each Employee can be a member of one and only one Department (or if they can
be members of more than one department you will have to handle that)
Each Accident results in the assignment of 0 to X points


From the above we can determine we will need (at least) the following tables

Departments (DepartmentID, DepartmentName)
Employees(EmployeeID, DepartmentID, EmployeeLastName, EmployeeFirstName,
etc)
AccidentTypes(AccidentTypeID, AccidentTypeDescription)
Accidents (AccidentID,
EmployeeID,AccidentTypeID,AccidentDate,PointsAssigned)

Accident_BodyParts(AccidentBodyPartID, AccidentID,BodyPartID)

BodyParts(BodyPartID, BodyPart)

Relationships
Department 1:M Employees
Employees 1:M Accidents
AccidentTypes 1:M Accidents
BodyParts 1:M Accident_BodyParts
Accidents 1:M Accident_BodyParts

The above should be enough to get started.

Ed Warren
 
G

Guest

Thanks Ed, I'll let you know the outcome
Oh one more thing I created the Bodyparts and department as a combox
(separate tables) is that ok
 
E

Ed Warren

Not only Ok that is the way it should be. Note, that is the way I have
suggested they be configured.

Ed Warren.
 
G

Guest

Hi Ed
I link everything like you said and I am getting 1 to1 on all except dept to
employee(1 to many) what am I doing wrong, also do I need a table for the
total of accidents
by emp, depart, points, grandtotal
 
G

Guest

I'm sorry Ed, I corrected my mistake I did not link them correctly. Now the
only problem i see now is with the accident type I have that as a 1 to 1
relation
 
E

Ed Warren

????
Therefore::

AccidentType should be linked 1:M to Accidents (each Accident can be of 1
and only 1 type, but each accidentType can be linked to many accidents).

So the link should be AccidentType (AccidentTypeID) 1:M Accidents.
(AccidentTypeID, foreign key)

Ed Warren.
 
G

Guest

Thanks I have them all link correctly. I create a table for Total accidents
and I link that table to employees but as i enter my information on the form
all the tables are blank except for employees, what did I do wrong
 
E

Ed Warren

??

There are lots of 'what I did wrong' ways to go I don't have a clue what
you have or have not done so here are some thoughts.

Now you have the tables built, you need to build forms to put data into the
tables.


You will need a form for each table.
One to enter employee data
one to enter the types of accidents
one to enter the type of injury
one to enter the departments
etc.

After you get through building forms you will need to build some reports to
provide the final output of the system.

Remember:
Tables -- hold data (don't let the user near them)
Queries -- retrieve\maintain data in the form\format you want and do the
calculations required
Forms -- Enter Data
Reports -- 'report data'
Modules -- contain the buisness logic needed in VBA code


Then you will want a form based on the Employee table with a subform (based
on the Accidents, for entering the accidents that employee has been involved
in). That SubForm should be linked to the employee table using the
EmployeeID field as (child,parent). This SubForm should contain a dropdown
list box to all selection of the type of injury from the injury table, plus
other fields as required to fill in the required data fields.

Likewise you in the employee form you will have a dropdown box to select the
department from the department table.

And around, around, we go....

Ed Warren
 
G

Guest

Thank you Ed....everything works great except the total fields
I need to total all accidents (separately)by employee, department, driving
points and a grand total of all accidents. So far I create a qry to start, in
the qry I use the count function to count the total by department, employee
and points. I use the (*) to count total accidents but nothing works can you
help me
 
E

Ed Warren

It would help if you would select View "sql" in your query then , copy the
sql code to the clipboard, then paste it here so we could actually see your
query code. Otherwise, we are not able to help and would probably hinder.

Ed Warren.
 
G

Guest

Here's my SQL:
SELECT [tbl EmpAccidents].[tbl EmpAccidentsID], [tbl
EmpAccidents].EmployeeID, [tbl EmpAccidents].FirstName, [tbl
EmpAccidents].LastName, [tbl EmpAccidents].JobTitle, [tbl
EmpAccidents].Address, [tbl EmpAccidents].City, [tbl EmpAccidents].Zipcode,
[tbl EmpAccidents].DOB, [tbl Accidents].AccidentDate, [tbl
Accidents].AccidentType, [tbl Accidents].[Date of Injury], [tbl
Accidents].[Time of Injury], [tbl Accidents].[Location of accident], [tbl
Accidents].[Time work began], [tbl Accidents].[Date employer notified], [tbl
Accidents].Summary, [tbl Accidents].[Physician/Hospital], [tbl
Accidents].[Physician/Hospital Address], [tbl Accidents].[No treatment], [tbl
Accidents].[Minor:by employee], [tbl Accidents].[Minor:clinic/hospital], [tbl
Accidents].[Emergency care], [tbl Accidents].[Hospitalized>24 hrs], [tbl
Accidents].PointsAssigned, [tbl Accidents].[Report prepared by], [tbl
Accidents].Position, [tbl Accidents].Telephone, [tbl Accidents].[Date of
Report], [tbl Body Parts].[Part of body affected], [tbl
CoDepartments].DepartmentName, [tbl Total Accidents].TotalbyEmp, [tbl Total
Accidents].TotalbyDept, [tbl Total Accidents].TotDrivingPoints, [tbl Total
Accidents].Total
FROM ([tbl EmpAccidents] INNER JOIN (([tbl Body Parts] INNER JOIN [tbl
CoDepartments] ON [tbl Body Parts].PartofBodyID = [tbl
CoDepartments].DepartmentID) INNER JOIN [tbl Accidents] ON [tbl
CoDepartments].DepartmentID = [tbl Accidents].AccidentID) ON [tbl
EmpAccidents].[tbl EmpAccidentsID] = [tbl Accidents].AccidentID) INNER JOIN
[tbl Total Accidents] ON [tbl Accidents].AccidentID = [tbl Total
Accidents].AccidentID;
 
E

Ed Warren

This is enough to make my head swim.
It would appear you are trying to get a list of all accidents combined with
a total number of accidents.

--------------------------------------------------individual accidents
[tbl EmpAccidents].[tbl EmpAccidentsID],
[tbl EmpAccidents].EmployeeID,
[tbl EmpAccidents].FirstName,
[tbl EmpAccidents].LastName,
[tbl EmpAccidents].JobTitle,
[tbl EmpAccidents].Address,
[tbl EmpAccidents].City,
[tbl EmpAccidents].Zipcode,
[tbl EmpAccidents].DOB,
[tbl Accidents].AccidentDate,
[tbl Accidents].AccidentType,
[tbl Accidents].[Date of Injury],
[tbl Accidents].[Time of Injury],
[tbl Accidents].[Location of accident],
[tbl Accidents].[Time work began],
[tbl Accidents].[Date employer notified],
[tbl Accidents].Summary,
[tbl Accidents].[Physician/Hospital],
[tbl Accidents].[Physician/Hospital Address],
[tbl Accidents].[No treatment],
[tbl Accidents].[Minor:by employee],
[tbl Accidents].[Minor:clinic/hospital],
[tbl Accidents].[Emergency care],
[tbl Accidents].[Hospitalized>24 hrs],
[tbl Accidents].PointsAssigned,
[tbl Accidents].[Report prepared by],
[tbl Accidents].Position,
[tbl Accidents].Telephone,
[tbl Accidents].[Date of Report],
[tbl Body Parts].[Part of body affected],
[tbl CoDepartments].DepartmentName,

'----------------------------------------accident summary
[tbl Total Accidents].TotalbyEmp,
[tbl Total Accidents].TotalbyDept,
[tbl Total Accidents].TotDrivingPoints,
[tbl Total Accidents].Total
'---------------------------------------------------

If I understand your comments correctly, the TotalbyEmp, etc. are not
correct.

So how are you generating the [tblTotalAccidents] and what is the key field
for it?
It appears to contain rows like

[EmployeeTotalAccidents] [DepartmentTotalAccidents] and [TotalAccidents]
which logically would not go together.


I would not use a table but a set of queries.

qryTotalbyEmp :

SELECT [EmployeeID], Count([EmpAccidentID) AS TotEmpAccidents
FROM [EmpAccidents]
GROUP BY [EmployeeID];

This will provide a set of data like
EmployeeID TotEmpAccidents
1 3
2 1
3 0
4 2
--------------
a similar query is required for getting the number of accidents for a
department

Select [DepartmentID], Count([EmpAccidentID]) as TotDeptAccidents
From [EmpAccidents]
Group By [DepartmentID];

Then to get the final total of all accidents

Select Count[EmpAccidentID] as TotdepTaccidents
From [EmpAccidents];
(this should return only one number, the total count of accidents.


Ed Warren.






LHEMA said:
Here's my SQL:
SELECT [tbl EmpAccidents].[tbl EmpAccidentsID], [tbl
EmpAccidents].EmployeeID, [tbl EmpAccidents].FirstName, [tbl
EmpAccidents].LastName, [tbl EmpAccidents].JobTitle, [tbl
EmpAccidents].Address, [tbl EmpAccidents].City, [tbl
EmpAccidents].Zipcode,
[tbl EmpAccidents].DOB, [tbl Accidents].AccidentDate, [tbl
Accidents].AccidentType, [tbl Accidents].[Date of Injury], [tbl
Accidents].[Time of Injury], [tbl Accidents].[Location of accident], [tbl
Accidents].[Time work began], [tbl Accidents].[Date employer notified],
[tbl
Accidents].Summary, [tbl Accidents].[Physician/Hospital], [tbl
Accidents].[Physician/Hospital Address], [tbl Accidents].[No treatment],
[tbl
Accidents].[Minor:by employee], [tbl Accidents].[Minor:clinic/hospital],
[tbl
Accidents].[Emergency care], [tbl Accidents].[Hospitalized>24 hrs], [tbl
Accidents].PointsAssigned, [tbl Accidents].[Report prepared by], [tbl
Accidents].Position, [tbl Accidents].Telephone, [tbl Accidents].[Date of
Report], [tbl Body Parts].[Part of body affected], [tbl
CoDepartments].DepartmentName, [tbl Total Accidents].TotalbyEmp, [tbl
Total
Accidents].TotalbyDept, [tbl Total Accidents].TotDrivingPoints, [tbl Total
Accidents].Total
FROM ([tbl EmpAccidents] INNER JOIN (([tbl Body Parts] INNER JOIN [tbl
CoDepartments] ON [tbl Body Parts].PartofBodyID = [tbl
CoDepartments].DepartmentID) INNER JOIN [tbl Accidents] ON [tbl
CoDepartments].DepartmentID = [tbl Accidents].AccidentID) ON [tbl
EmpAccidents].[tbl EmpAccidentsID] = [tbl Accidents].AccidentID) INNER
JOIN
[tbl Total Accidents] ON [tbl Accidents].AccidentID = [tbl Total
Accidents].AccidentID;
--
LHEMA


Ed Warren said:
It would help if you would select View "sql" in your query then , copy
the
sql code to the clipboard, then paste it here so we could actually see
your
query code. Otherwise, we are not able to help and would probably
hinder.

Ed Warren.
 
G

Guest

Thanks Warren the help you gave me work, my database is working great except
for the driving points. I need to show the total of driving points per
employee if they receive any for example: Frank receive total of 4 points and
Albert receive toal of 3 points when I preview the report i need for it to
show Frank points with the accidents he receive and Albert points with the
accidents he receive, right now they are together as toal point of 7. How do
I separate the two. --
LHEMA


Ed Warren said:
This is enough to make my head swim.
It would appear you are trying to get a list of all accidents combined with
a total number of accidents.

--------------------------------------------------individual accidents
[tbl EmpAccidents].[tbl EmpAccidentsID],
[tbl EmpAccidents].EmployeeID,
[tbl EmpAccidents].FirstName,
[tbl EmpAccidents].LastName,
[tbl EmpAccidents].JobTitle,
[tbl EmpAccidents].Address,
[tbl EmpAccidents].City,
[tbl EmpAccidents].Zipcode,
[tbl EmpAccidents].DOB,
[tbl Accidents].AccidentDate,
[tbl Accidents].AccidentType,
[tbl Accidents].[Date of Injury],
[tbl Accidents].[Time of Injury],
[tbl Accidents].[Location of accident],
[tbl Accidents].[Time work began],
[tbl Accidents].[Date employer notified],
[tbl Accidents].Summary,
[tbl Accidents].[Physician/Hospital],
[tbl Accidents].[Physician/Hospital Address],
[tbl Accidents].[No treatment],
[tbl Accidents].[Minor:by employee],
[tbl Accidents].[Minor:clinic/hospital],
[tbl Accidents].[Emergency care],
[tbl Accidents].[Hospitalized>24 hrs],
[tbl Accidents].PointsAssigned,
[tbl Accidents].[Report prepared by],
[tbl Accidents].Position,
[tbl Accidents].Telephone,
[tbl Accidents].[Date of Report],
[tbl Body Parts].[Part of body affected],
[tbl CoDepartments].DepartmentName,

'----------------------------------------accident summary
[tbl Total Accidents].TotalbyEmp,
[tbl Total Accidents].TotalbyDept,
[tbl Total Accidents].TotDrivingPoints,
[tbl Total Accidents].Total
'---------------------------------------------------

If I understand your comments correctly, the TotalbyEmp, etc. are not
correct.

So how are you generating the [tblTotalAccidents] and what is the key field
for it?
It appears to contain rows like

[EmployeeTotalAccidents] [DepartmentTotalAccidents] and [TotalAccidents]
which logically would not go together.


I would not use a table but a set of queries.

qryTotalbyEmp :

SELECT [EmployeeID], Count([EmpAccidentID) AS TotEmpAccidents
FROM [EmpAccidents]
GROUP BY [EmployeeID];

This will provide a set of data like
EmployeeID TotEmpAccidents
1 3
2 1
3 0
4 2
--------------
a similar query is required for getting the number of accidents for a
department

Select [DepartmentID], Count([EmpAccidentID]) as TotDeptAccidents
From [EmpAccidents]
Group By [DepartmentID];

Then to get the final total of all accidents

Select Count[EmpAccidentID] as TotdepTaccidents
From [EmpAccidents];
(this should return only one number, the total count of accidents.


Ed Warren.






LHEMA said:
Here's my SQL:
SELECT [tbl EmpAccidents].[tbl EmpAccidentsID], [tbl
EmpAccidents].EmployeeID, [tbl EmpAccidents].FirstName, [tbl
EmpAccidents].LastName, [tbl EmpAccidents].JobTitle, [tbl
EmpAccidents].Address, [tbl EmpAccidents].City, [tbl
EmpAccidents].Zipcode,
[tbl EmpAccidents].DOB, [tbl Accidents].AccidentDate, [tbl
Accidents].AccidentType, [tbl Accidents].[Date of Injury], [tbl
Accidents].[Time of Injury], [tbl Accidents].[Location of accident], [tbl
Accidents].[Time work began], [tbl Accidents].[Date employer notified],
[tbl
Accidents].Summary, [tbl Accidents].[Physician/Hospital], [tbl
Accidents].[Physician/Hospital Address], [tbl Accidents].[No treatment],
[tbl
Accidents].[Minor:by employee], [tbl Accidents].[Minor:clinic/hospital],
[tbl
Accidents].[Emergency care], [tbl Accidents].[Hospitalized>24 hrs], [tbl
Accidents].PointsAssigned, [tbl Accidents].[Report prepared by], [tbl
Accidents].Position, [tbl Accidents].Telephone, [tbl Accidents].[Date of
Report], [tbl Body Parts].[Part of body affected], [tbl
CoDepartments].DepartmentName, [tbl Total Accidents].TotalbyEmp, [tbl
Total
Accidents].TotalbyDept, [tbl Total Accidents].TotDrivingPoints, [tbl Total
Accidents].Total
FROM ([tbl EmpAccidents] INNER JOIN (([tbl Body Parts] INNER JOIN [tbl
CoDepartments] ON [tbl Body Parts].PartofBodyID = [tbl
CoDepartments].DepartmentID) INNER JOIN [tbl Accidents] ON [tbl
CoDepartments].DepartmentID = [tbl Accidents].AccidentID) ON [tbl
EmpAccidents].[tbl EmpAccidentsID] = [tbl Accidents].AccidentID) INNER
JOIN
[tbl Total Accidents] ON [tbl Accidents].AccidentID = [tbl Total
Accidents].AccidentID;
--
LHEMA


Ed Warren said:
It would help if you would select View "sql" in your query then , copy
the
sql code to the clipboard, then paste it here so we could actually see
your
query code. Otherwise, we are not able to help and would probably
hinder.

Ed Warren.


Thank you Ed....everything works great except the total fields
I need to total all accidents (separately)by employee, department,
driving
points and a grand total of all accidents. So far I create a qry to
start,
in
the qry I use the count function to count the total by department,
employee
and points. I use the (*) to count total accidents but nothing works
can
you
help me
--
LHEMA


:

??

There are lots of 'what I did wrong' ways to go I don't have a clue
what
you have or have not done so here are some thoughts.

Now you have the tables built, you need to build forms to put data
into
the
tables.


You will need a form for each table.
One to enter employee data
one to enter the types of accidents
one to enter the type of injury
one to enter the departments
etc.

After you get through building forms you will need to build some
reports
to
provide the final output of the system.

Remember:
Tables -- hold data (don't let the user near them)
Queries -- retrieve\maintain data in the form\format you want and do
the
calculations required
Forms -- Enter Data
Reports -- 'report data'
Modules -- contain the buisness logic needed in VBA code


Then you will want a form based on the Employee table with a subform
(based
on the Accidents, for entering the accidents that employee has been
involved
in). That SubForm should be linked to the employee table using the
EmployeeID field as (child,parent). This SubForm should contain a
dropdown
list box to all selection of the type of injury from the injury table,
plus
other fields as required to fill in the required data fields.

Likewise you in the employee form you will have a dropdown box to
select
the
department from the department table.

And around, around, we go....

Ed Warren


Thanks I have them all link correctly. I create a table for Total
accidents
and I link that table to employees but as i enter my information on
the
form
all the tables are blank except for employees, what did I do wrong
--
LHEMA


:

????
Each AccidentType can have 0 to many Accidents

Therefore::

AccidentType should be linked 1:M to Accidents (each Accident can
be
of 1
and only 1 type, but each accidentType can be linked to many
accidents).

So the link should be AccidentType (AccidentTypeID) 1:M Accidents.
(AccidentTypeID, foreign key)

Ed Warren.

I'm sorry Ed, I corrected my mistake I did not link them
correctly.
Now
the
only problem i see now is with the accident type I have that as a
1
to
1
relation
--
LHEMA


:

Hi Ed
I link everything like you said and I am getting 1 to1 on all
except
dept
to
employee(1 to many) what am I doing wrong, also do I need a
table
for
the
total of accidents
by emp, depart, points, grandtotal
--
LHEMA


:

Not only Ok that is the way it should be. Note, that is the
way I
have
suggested they be configured.

Ed Warren.

Thanks Ed, I'll let you know the outcome
Oh one more thing I created the Bodyparts and department as
a
combox
(separate tables) is that ok
--
LHEMA


:
 
E

Ed Warren

add a grouping band to your report with a header and footer groupby the
employee then add a Text Field with the data property set to =Sum(points) to
the footer for that group.

Ed Warren

LHEMA said:
Thanks Warren the help you gave me work, my database is working great
except
for the driving points. I need to show the total of driving points per
employee if they receive any for example: Frank receive total of 4 points
and
Albert receive toal of 3 points when I preview the report i need for it to
show Frank points with the accidents he receive and Albert points with the
accidents he receive, right now they are together as toal point of 7. How
do
I separate the two. --
LHEMA


Ed Warren said:
This is enough to make my head swim.
It would appear you are trying to get a list of all accidents combined
with
a total number of accidents.

--------------------------------------------------individual accidents
[tbl EmpAccidents].[tbl EmpAccidentsID],
[tbl EmpAccidents].EmployeeID,
[tbl EmpAccidents].FirstName,
[tbl EmpAccidents].LastName,
[tbl EmpAccidents].JobTitle,
[tbl EmpAccidents].Address,
[tbl EmpAccidents].City,
[tbl EmpAccidents].Zipcode,
[tbl EmpAccidents].DOB,
[tbl Accidents].AccidentDate,
[tbl Accidents].AccidentType,
[tbl Accidents].[Date of Injury],
[tbl Accidents].[Time of Injury],
[tbl Accidents].[Location of accident],
[tbl Accidents].[Time work began],
[tbl Accidents].[Date employer notified],
[tbl Accidents].Summary,
[tbl Accidents].[Physician/Hospital],
[tbl Accidents].[Physician/Hospital Address],
[tbl Accidents].[No treatment],
[tbl Accidents].[Minor:by employee],
[tbl Accidents].[Minor:clinic/hospital],
[tbl Accidents].[Emergency care],
[tbl Accidents].[Hospitalized>24 hrs],
[tbl Accidents].PointsAssigned,
[tbl Accidents].[Report prepared by],
[tbl Accidents].Position,
[tbl Accidents].Telephone,
[tbl Accidents].[Date of Report],
[tbl Body Parts].[Part of body affected],
[tbl CoDepartments].DepartmentName,

'----------------------------------------accident summary
[tbl Total Accidents].TotalbyEmp,
[tbl Total Accidents].TotalbyDept,
[tbl Total Accidents].TotDrivingPoints,
[tbl Total Accidents].Total
'---------------------------------------------------

If I understand your comments correctly, the TotalbyEmp, etc. are not
correct.

So how are you generating the [tblTotalAccidents] and what is the key
field
for it?
It appears to contain rows like

[EmployeeTotalAccidents] [DepartmentTotalAccidents] and
[TotalAccidents]
which logically would not go together.


I would not use a table but a set of queries.

qryTotalbyEmp :

SELECT [EmployeeID], Count([EmpAccidentID) AS TotEmpAccidents
FROM [EmpAccidents]
GROUP BY [EmployeeID];

This will provide a set of data like
EmployeeID TotEmpAccidents
1 3
2 1
3 0
4 2
--------------
a similar query is required for getting the number of accidents for a
department

Select [DepartmentID], Count([EmpAccidentID]) as TotDeptAccidents
From [EmpAccidents]
Group By [DepartmentID];

Then to get the final total of all accidents

Select Count[EmpAccidentID] as TotdepTaccidents
From [EmpAccidents];
(this should return only one number, the total count of accidents.


Ed Warren.






LHEMA said:
Here's my SQL:
SELECT [tbl EmpAccidents].[tbl EmpAccidentsID], [tbl
EmpAccidents].EmployeeID, [tbl EmpAccidents].FirstName, [tbl
EmpAccidents].LastName, [tbl EmpAccidents].JobTitle, [tbl
EmpAccidents].Address, [tbl EmpAccidents].City, [tbl
EmpAccidents].Zipcode,
[tbl EmpAccidents].DOB, [tbl Accidents].AccidentDate, [tbl
Accidents].AccidentType, [tbl Accidents].[Date of Injury], [tbl
Accidents].[Time of Injury], [tbl Accidents].[Location of accident],
[tbl
Accidents].[Time work began], [tbl Accidents].[Date employer notified],
[tbl
Accidents].Summary, [tbl Accidents].[Physician/Hospital], [tbl
Accidents].[Physician/Hospital Address], [tbl Accidents].[No
treatment],
[tbl
Accidents].[Minor:by employee], [tbl
Accidents].[Minor:clinic/hospital],
[tbl
Accidents].[Emergency care], [tbl Accidents].[Hospitalized>24 hrs],
[tbl
Accidents].PointsAssigned, [tbl Accidents].[Report prepared by], [tbl
Accidents].Position, [tbl Accidents].Telephone, [tbl Accidents].[Date
of
Report], [tbl Body Parts].[Part of body affected], [tbl
CoDepartments].DepartmentName, [tbl Total Accidents].TotalbyEmp, [tbl
Total
Accidents].TotalbyDept, [tbl Total Accidents].TotDrivingPoints, [tbl
Total
Accidents].Total
FROM ([tbl EmpAccidents] INNER JOIN (([tbl Body Parts] INNER JOIN [tbl
CoDepartments] ON [tbl Body Parts].PartofBodyID = [tbl
CoDepartments].DepartmentID) INNER JOIN [tbl Accidents] ON [tbl
CoDepartments].DepartmentID = [tbl Accidents].AccidentID) ON [tbl
EmpAccidents].[tbl EmpAccidentsID] = [tbl Accidents].AccidentID) INNER
JOIN
[tbl Total Accidents] ON [tbl Accidents].AccidentID = [tbl Total
Accidents].AccidentID;
--
LHEMA


:

It would help if you would select View "sql" in your query then , copy
the
sql code to the clipboard, then paste it here so we could actually see
your
query code. Otherwise, we are not able to help and would probably
hinder.

Ed Warren.


Thank you Ed....everything works great except the total fields
I need to total all accidents (separately)by employee, department,
driving
points and a grand total of all accidents. So far I create a qry to
start,
in
the qry I use the count function to count the total by department,
employee
and points. I use the (*) to count total accidents but nothing works
can
you
help me
--
LHEMA


:

??

There are lots of 'what I did wrong' ways to go I don't have a
clue
what
you have or have not done so here are some thoughts.

Now you have the tables built, you need to build forms to put data
into
the
tables.


You will need a form for each table.
One to enter employee data
one to enter the types of accidents
one to enter the type of injury
one to enter the departments
etc.

After you get through building forms you will need to build some
reports
to
provide the final output of the system.

Remember:
Tables -- hold data (don't let the user near them)
Queries -- retrieve\maintain data in the form\format you want and
do
the
calculations required
Forms -- Enter Data
Reports -- 'report data'
Modules -- contain the buisness logic needed in VBA code


Then you will want a form based on the Employee table with a
subform
(based
on the Accidents, for entering the accidents that employee has been
involved
in). That SubForm should be linked to the employee table using the
EmployeeID field as (child,parent). This SubForm should contain a
dropdown
list box to all selection of the type of injury from the injury
table,
plus
other fields as required to fill in the required data fields.

Likewise you in the employee form you will have a dropdown box to
select
the
department from the department table.

And around, around, we go....

Ed Warren


Thanks I have them all link correctly. I create a table for Total
accidents
and I link that table to employees but as i enter my information
on
the
form
all the tables are blank except for employees, what did I do
wrong
--
LHEMA


:

????
Each AccidentType can have 0 to many Accidents

Therefore::

AccidentType should be linked 1:M to Accidents (each Accident
can
be
of 1
and only 1 type, but each accidentType can be linked to many
accidents).

So the link should be AccidentType (AccidentTypeID) 1:M
Accidents.
(AccidentTypeID, foreign key)

Ed Warren.

I'm sorry Ed, I corrected my mistake I did not link them
correctly.
Now
the
only problem i see now is with the accident type I have that
as a
1
to
1
relation
--
LHEMA


:

Hi Ed
I link everything like you said and I am getting 1 to1 on all
except
dept
to
employee(1 to many) what am I doing wrong, also do I need a
table
for
the
total of accidents
by emp, depart, points, grandtotal
--
LHEMA


:

Not only Ok that is the way it should be. Note, that is the
way I
have
suggested they be configured.

Ed Warren.

Thanks Ed, I'll let you know the outcome
Oh one more thing I created the Bodyparts and department
as
a
combox
(separate tables) is that ok
--
LHEMA


:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top