Hello:
I am trying to put together a query that determines employees who are in a department that has had an incident with in the last two months. I have a query that determines who has had and incident and the department they were in when they had the incident: - SELECT Q_RestrictedEmployees.empID, Q_RestrictedEmployees.empNo, Q_RestrictedEmployees.empName, Q_RestrictedEmployees.incidentDt, Q_RestrictedEmployees.RestrictionEnd, (Select top 1 dept from Q_DeptTrans where Q_DeptTrans.empID=Q_RestrictedEmployees.empID and Q_DeptTrans.depttransDt<=Q_RestrictedEmployees.incidentDt) AS Dept_At_Time_Of_Incident
-
FROM Q_CurrentDepts INNER JOIN Q_RestrictedEmployees ON Q_CurrentDepts.empID = Q_RestrictedEmployees.empID;
-
I believe i need to use this query in conjunction with another query to match anyone in a department from above to all other employees in that department, so I may penalize that department as a whole. I have a query that tells me all employed currently and their current department, but I used that one in the above query to get my record set. How can I find other employees with in the department of the offending employees?
Mar 16 '09
63 3605 ChipR 1,287
Recognized Expert Top Contributor
Just make a JOIN or query that includes it, that's what you need.
There in lies the problem. I have a query that has the vacationTime as well as the current department of the employee, but any query that I use the qryCurrentEmpDe pt in will not be updateable because that query isn't updateable. If i take that query away, i can update it, but then i would only have access to the vacatime TIme, and not the departmentID. @ChipR ChipR 1,287
Recognized Expert Top Contributor
I see what you are saying now. That first query you listed is qryCurrentEmpDe pt? I guess tell me your table structures. It can't be that difficult to get the employee's department in an updatable query.
Here is my table structure and some sample data:
Employee: empID, empNo, empName -
1, 12345, Thomas Johnson
-
2, 67890, Tom Mantia
-
3, 54321, JohnTest
-
Dept: deptID, dept -
1, Engineering
-
2, Yard
-
3, Sandblast
DeptTrans: deptTransID, deptID, empID, transDt, transEndDt -
1, 1, 1, 1.1.09, Null
-
2, 2, 1, 12.1.08, 12.31.08
-
3, 3, 2, 1.2.09, Null
-
4, 3, 3, 1.3.09, Null
(One employee may have transferred departments many times)
(One employee may be assigned vacation time many times)
VacationTime: vacaID, empID, empEarnedTime, vacaTimeAwardDt -
1, 1, 8, 2.1.09
-
2, 2, 0, Null
-
3, 3, 4, 2.1.09
(One employee maybe have many incidents)
EmpIncidents: incidentID, empID, incidentTYpeID, incidentDt -
1, 1, 2, 12.2.08
-
2, 2, 2, 1.4.09
(One employee can have many types of incidents)
IncidentTypeId: incidentTypeID, incident (the only incidents that
allow an employee and his dept to lose time are types 2 and 3) -
1, NonRecordable
-
2, Recordable
-
3, Lost-Time
@ChipR ChipR 1,287
Recognized Expert Top Contributor
I don't get it. What department is an employee in if they never transferred?
If they never transferred their transEndDt is Null, meaning they are still in their current department DeptTrans: deptTransID, deptID, empID, transDt, transEndDt -
-
1. 1, 1, 1, 1.1.09, Null
-
2. 2, 2, 1, 12.1.08, 12.31.08
-
3. 3, 3, 2, 1.2.09, Null
-
4. 4, 3, 3, 1.3.09, Null
Specifically in the above example, empID 1 has transferred departments twice. His current dept is deptID 1 and his end date is Null. He was in deptID 2 all of 2008 and on 1.1.09, he transferred to dept 1 and is still apart of that dept.
ChipR 1,287
Recognized Expert Top Contributor
Ok, assuming you put in a transfer when they start the job.
How about : - SELECT Employee.empID, Employee.empNo, Employee.empName, DeptTrans.deptID FROM Employee, DeptTrans WHERE Employee.empID = DeptTrans.empID AND transEndDT IS NULL
Correction, I made it updateable :)
---
Correct, when an employee starts a job, they are put in the transfer table. That query works, but it isn't updateable either.
@ChipR ChipR 1,287
Recognized Expert Top Contributor
That simple query by itself cannot be updated? I just tried a query with IS NULL and didn't have a problem. I don't see why that would be.
ChipR 1,287
Recognized Expert Top Contributor
Never mind, it's not updatable after the join. What the heck.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Kevin Michael Reed |
last post by:
------=_NextPart_000_002B_01C34DF8.C34C94F0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Assistance required.
I have 3 tables:
|
by: Bill |
last post by:
Good Day;
I would appreciate assistance developing a query that I haven't been
able to develop without using a second table. I wish to count the
number of records that are still open on the first of each month.
Each record has an open date and a close date or the close date is
null i.e., the record is not yet closed. I've previously...
|
by: Rolan |
last post by:
I'm using Access 97 and need some assistance in sorting out a proper
DSum expression, or maybe even DCount might be an alternative. I have
tried numerous combinations, but with no apparent success.
The DSum function relates to a subform (sfrmCost) with a text box
(RefCost) which is intended to be the container for a total from a
query...
|
by: Dalan |
last post by:
I seemed to be having problems with structuring the use of NZ with a
DSum expression. Having tried numerous variations of the expression
without success, I'm asking for assistance.
First some background (Access 97) - the DSum expressions are being
used in grand total text boxes on the footer of a subform. And when
viewing the subform in the...
|
by: MLH |
last post by:
I apologize in advance to forum readers noticing this somewhat
redundant post. I fear that my Subject Heading was ill-chosen in
earlier post I made on this topic. Am hoping that a clearer Subject
heading will attract the knowledgeable forum contributors I'm
seeking. Thank-you...
I'm being academically challenged trying to build a...
| |
by: Dalan |
last post by:
I presume that using an open recordset method is the preferred method
of accomplishing what I'm trying to do. Of course, if there are other
options that would work, feel free to share them.
I need to provide a means of scanning one field for all records and to
trigger a message upon opening the form for alerting a user that
maintenance...
|
by: Dalan |
last post by:
I'm experiencing a Query Syntax Error with an Access 97 Db. Actually,
the query performs as expected when adding any new records or editing
existing ones and even deleting records, EXCEPT when the last record
on any related subform is deleted, then it generates a Runtime Error
3075 - Syntax error (missing operator) in query expression 'IDRef =...
|
by: Dalan |
last post by:
I'm not certain if this is doable in the manner explained below, but
surely there have been others who have done something similar. So
whatever insight and assistance that can be provided will be much
appreciated.
I working with a separate Update Query (well several) that consolidate
various goods from separate tables for access and...
|
by: Rolan |
last post by:
I know what I want to do regarding the average cost for inventory, but
need some assistance to sort out some of the details to finalize an
inventory table and query. Essentially, the information is needed for
year end reporting and not for on-going review. Below is an example
that summarizes it all.
tblMain/frmMain /IDTag...
|
by: cory.craig |
last post by:
I am trying to pull some "notes" from a sql database.....the notes that
are put into the database come via the web and the user is entering it
for a certain task. they are stored in their own table and field and
get assigned and incremental ID #.
I want to be able to pull up the latest entry to the task, not all of
the notes just the...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |