Table relationship many to one showing all records.

Kill_Switch

Go Easy I'm New
Local time
Today, 08:33
Joined
Apr 23, 2009
Messages
58
Good day everyone.

I thought I had everything set correct, but it would seem not.

I am trying to have a table, where we can track what area's of the building people were employed. Many employment areas to one employee.

Problem being, when click on the "Area of Employment" and the form opens. It opens to all records, not just that employee's. I can add a record but it will appear on each record.

Thank you, very much, in advance for any of your time.
table relationship.PNG

Form.PNG


Employment form VBA if that helps
Code:
Private Sub Add_Employment_Click()
    DoCmd.GoToRecord , , acNewRec
    START_DATE = Now()
End Sub


Private Sub Command368_Click()
DoCmd.RunCommand acCmdCloseWindow
End Sub

Private Sub Delete_Record_Click()

If MsgBox("Are you sure you want to delete the area of employment?", vbYesNo, "Warning!") = vbYes Then
    DoCmd.RunCommand acCmdDeleteRecord
Else
    DoCmd.OpenForm "frm_EMPLOYMENT"
End If
End Sub

Private Sub Form_GotFocus()
    EMPLOYED_AREA.SelStart = 0
End Sub
 

theDBguy

I’m here to help
Staff member
Local time
Today, 04:33
Joined
Oct 29, 2018
Messages
21,473
Can you post a sample copy of the database with test data?
 

Kill_Switch

Go Easy I'm New
Local time
Today, 08:33
Joined
Apr 23, 2009
Messages
58
I can try in the morning, will have to sanitize the data.
 

Gasman

Enthusiastic Amateur
Local time
Today, 12:33
Joined
Sep 21, 2011
Messages
14,305
I can try in the morning, will have to sanitize the data.
 

Kill_Switch

Go Easy I'm New
Local time
Today, 08:33
Joined
Apr 23, 2009
Messages
58
So an employment area only has one employee - ever

are you sure you don’t mean many to many?
I had a long self discussion. I don't think it would be a many to many, I say this the employment area is per employee is by each employees experience. If I didn't want to track their start and end dates, then I would consider having a junction table for a many to many.

1 employee can have multiple unique time spent at a employment area at work.

I would consider that a many to one. Am I wrong? I mean this being inquisitive not sarcastic (emotion in text is hard:) )
 

jdraw

Super Moderator
Staff member
Local time
Today, 07:33
Joined
Jan 23, 2006
Messages
15,379
Still not clear to me.
Consider, the following: with associated dates/duration.
Bob works in IT.
Joe works in Plumbing
Ted works in Accounting
**Joe gets new job in IT
**Bob gets moved to Corporate Management

If your Employment areas are Accounting, IT, Plumbing and Corporate Management, then what exactly do you want to report?

-here is/are the work area(s) where Employee X has worked
-here is/are the Employee(s) who have worked in WorkArea X
 

mike60smart

Registered User.
Local time
Today, 12:33
Joined
Aug 6, 2017
Messages
1,905
Still not clear to me.
Consider, the following:
Bob works in IT.
Joe works in Plumbing
Ted works in Accounting
**Joe gets new job in IT
**Bob gets moved to Corporate Management

If your Employment areas are Accounting, IT, Plumbing and Corporate Management, then what exactly do you want to report?

-here is/are the work area(s) where Employee X has worked
-here is/are the Employee(s) who have worked in WorkArea X
I would imaging a Form where you select an Employee
with a Subform that allows you to keep the History of the Employees Departments
 

jdraw

Super Moderator
Staff member
Local time
Today, 07:33
Joined
Jan 23, 2006
Messages
15,379
I agree Mike. Was editing while you posted.
Sounds like Many Employees and Many Work areas and employees can relocate (possibly many times).
I also note that the OP offers an Option to delete workarea(s)??
Code:
If MsgBox("Are you sure you want to delete the area of employment?", vbYesNo, "Warning!") = vbYes Then
    DoCmd.RunCommand acCmdDeleteRecord

So, history records could be deleted?? "Data integrity requirement"?
 

Kill_Switch

Go Easy I'm New
Local time
Today, 08:33
Joined
Apr 23, 2009
Messages
58
Still not clear to me.
Consider, the following:
Bob works in IT.
Joe works in Plumbing
Ted works in Accounting
**Joe gets new job in IT
**Bob gets moved to Corporate Management

If your Employment areas are Accounting, IT, Plumbing and Corporate Management, then what exactly do you want to report?

-here is/are the work area(s) where Employee X has worked
-here is/are the Employee(s) who have worked in WorkArea X
The 1st one.

Here are/is the work areas where employee x has worked.

IDEmployeeAreaYear


I would normally have a subform and just tell the parent and child relation, but it doesn't fit the template well.
 

Kill_Switch

Go Easy I'm New
Local time
Today, 08:33
Joined
Apr 23, 2009
Messages
58
I agree Mike. Was editing while you posted.
Sounds like Many Employees and Many Work areas and employees can relocate (possibly many times).
I also note that the OP offers an Option to delete workarea(s)??
Code:
If MsgBox("Are you sure you want to delete the area of employment?", vbYesNo, "Warning!") = vbYes Then
    DoCmd.RunCommand acCmdDeleteRecord

So, history records could be deleted??
Only if a record was added to the wrong person, just that employment timeline, not employment area completely.

Option to delete the record to be able to place it in its proper location.
 

mike60smart

Registered User.
Local time
Today, 12:33
Joined
Aug 6, 2017
Messages
1,905
Only if a record was added to the wrong person. Option to delete the record to be able to place it in its proper location.
Are you able to upload a zipped copy of the database with no confidential data?
 

jdraw

Super Moderator
Staff member
Local time
Today, 07:33
Joined
Jan 23, 2006
Messages
15,379
Only if a record was added to the wrong person. Option to delete the record to be able to place it in its proper location.

Wouldn't that be an edit to an existing (incorrectly entered) record?
 

Kill_Switch

Go Easy I'm New
Local time
Today, 08:33
Joined
Apr 23, 2009
Messages
58
Wouldn't that be an edit to an existing (incorrectly entered) record?
Essentially. If Bob had employment is Plumbing entered against them in error. The option to select that plumbing employment for Bob to be removed exists. I probably misused the term delete record.
 

jdraw

Super Moderator
Staff member
Local time
Today, 07:33
Joined
Jan 23, 2006
Messages
15,379
Sound like

Employee---->EmployeeEmploymentHistory<---WorkArea
 

Kill_Switch

Go Easy I'm New
Local time
Today, 08:33
Joined
Apr 23, 2009
Messages
58
I agree Mike. Was editing while you posted.
Sounds like Many Employees and Many Work areas and employees can relocate (possibly many times).
I also note that the OP offers an Option to delete workarea(s)??
Code:
If MsgBox("Are you sure you want to delete the area of employment?", vbYesNo, "Warning!") = vbYes Then
    DoCmd.RunCommand acCmdDeleteRecord

So, history records could be deleted?? "Data integrity requirement"?
It would be a many to many, except I want to track when they were employed in that area. So would that not make it one-to-many? It's unlikely there would be users with the same start and end dates for employment areas
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 06:33
Joined
Feb 28, 2001
Messages
27,186
I want to track when they were employed in that area.

This is a classic case of a junction table, which is how you do many-to-many, and you put the dates in junction-table entry that shows:
Code:
Employee ID (as FK to employee table)
Department or Area ID (as FK to department or area table)
Starting date
Ending date
 

Users who are viewing this thread

Top Bottom