Re: Employee Emergency

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Don (Don_at_discussions.microsoft.com)
Date: 02/22/05


Date: Tue, 22 Feb 2005 03:23:04 -0800

Hello Nikos,

sorry for the delay in responding, i couldnt logon yesterday but this works
just fine and thanks for the explanation.

I dont want to be a burden but i have another problem but this time it has
got to do with the availabilty.

"Nikos Yannacopoulos" wrote:

> Don,
>
> Assuming you have a fom called MyForm, with a control called ctlOrderID
> on it, in which you enter (or select, if the control is a
> listbox/combobox) the order ID to match to an employee, then the query
> can be modified to read that parameter doractly from the form. The query
> becomes:
>
> SELECT tblEmployeeskill.EmployeeID, tblOrderskill.OrderID,
> tblEmployee.Forename
> FROM tblEmployee INNER JOIN (tblEmployeeskill INNER JOIN tblOrderskill ON
> tblEmployeeskill.SkillID = tblOrderskill.SkillID) ON
> tblEmployee.EmployeeID =
> tblEmployeeskill.EmployeeID
> WHERE (((tblOrderskill.OrderID)= Forms![MyForm]![ctlOrderID]) AND
> ((tblOrderskill.SkillID)=DCount("[SkillID]","tblOrderskill","[OrderID]="
> & Forms![MyForm]![ctlOrderID])))
> GROUP BY tblEmployeeskill.EmployeeID, tblOrderskill.OrderID,
> tblEmployee.Forename;
>
> That is, I have used a reference to the control on the form instead of
> typing in the order ID.
>
> The logic behind the query (switch to design view to help understand):
> Join the two tables on SkillID, filter on OrderID; this returns all
> employees with at least one skill required by the order; one row per
> skill; Count SkillID from tblOrders = number of skills required matching
> a particular employee's skills (group on employee , so count per
> employee), so if that's equal to the number of skills required by the
> order regardless of employees (that's the DCOunt on tblOrders) in means
> that the particular employee has all the skills required. I'm not sure
> I'm explaining this very well, it's kind of complicated; it may help you
> understanding if you recobnstruct the query and see what you get step by
> step, i.e. first just the tables and the orderID filter, then the group
> by / count, then the DCount filter.
>
> HTH,
> Nikos
>
> Don wrote:
> > Thank you very much Nikos, this is the second time you have helped me !
> >
> > you dont understand how thankful i am, if there is anything i could do, just
> > ask.
> >
> > if i could i ask you for two things:
> >
> > 1 if you could explan the query to me becuase i want to understand it and
> > learn off it, if you dont mind.
> >
> > 2 will i be able to change the order id on the query on a form.
> >
> > thank you very much, you have just got me over a very big hurdle.
> >
> > thanks
> >
> > "Nikos Yannacopoulos" wrote:
> >
> >
> >>Don,
> >>
> >>Yes, I was wrong, and yes, I was close. Your new set of data was very
> >>helpful in establishing that... I changed the query to:
> >>
> >>SELECT tblEmployeeSlikk.EmployeeID, tblOrderskill.OrderID,
> >>tblEmployee.Forename
> >>FROM tblEmployee INNER JOIN (tblEmployeeskill INNER JOIN tblOrderskill
> >>ON tblEmployeeskill.SkillID = tblOrderskill.SkillID) ON
> >>tblEmployee.EmployeeID = tblEmployeeskill.EmployeeID
> >>WHERE (((tblOrderSkill.OrderID)=1))
> >>GROUP BY tblEmployeeSkill.EmployeeID, tblOrderskill.OrderID,
> >>tblEmployee.Forename
> >>HAVING
> >>(((Count(tblOrderSkill.SkillID))=DCount("[SkillID]","tblOrderSkill","[OrderID]=1")));
> >>
> >>and that seems to work. Wanna try it?
> >>
> >>Nikos
> >>
> >>Don wrote:
> >>
> >>>Hello Nikos,
> >>>i really appreicate your response, thank you.
> >>>
> >>>i tried the following query that you gave me, i change the table names to
> >>>the right ones.
> >>>
> >>>SELECT tblEmployeeskill.EmployeeID, tblOrderskill.OrderID,
> >>>tblEmployee.Forename
> >>>FROM tblEmployee INNER JOIN (tblEmployeeskill INNER JOIN tblOrderskill ON
> >>>tblEmployeeskill.SkillID = tblOrderskill.SkillID) ON tblEmployee.EmployeeID =
> >>>tblEmployeeskill.EmployeeID
> >>>WHERE (((tblOrderskill.OrderID)=1) AND
> >>>((tblOrderskill.SkillID)=DCount("[SkillID]","tblOrderskill","[OrderID]=1")))
> >>>GROUP BY tblEmployeeskill.EmployeeID, tblOrderskill.OrderID,
> >>>tblEmployee.Forename;
> >>>
> >>>this query retrieves all the names that can do skill 1 but i orders that can
> >>>do more then one skill, so skill 1 and 2 or skill 1 and 3, not 2, or 2 and 3.
> >>>
> >>>i am really sorry to be a pain but could you explain the query to me becuase
> >>>i think this could be modified to work, i think you have the right idea
> >>>there. Really sorry.
> >>>
> >>>p.s. i do appreciate all the help that i recieve.
> >>>
> >>>thanks, hope you can help.
> >>>
> >>>
> >>>"Nikos Yannacopoulos" wrote:
> >>>
> >>>
> >>>
> >>>>Don,
> >>>>
> >>>>This is quite interesting! Try this:
> >>>>
> >>>>SELECT tblEmployees.[Employee ID]
> >>>
> >>>>FROM tblEmployees INNER JOIN tblOrders ON tblEmployees.SkillID =
> >>>
> >>>>tblOrders.SkillID
> >>>>WHERE (((tblOrders.[Order ID])=1) AND
> >>>>((tblOrders.SkillID)=DCount("[SkillID]","tblOrders","[Order ID]=1")))
> >>>>GROUP BY tblEmployees.[Employee ID];
> >>>>
> >>>>where I have assumed table names tblEmployees and tblOrders
> >>>>
> >>>>HTH,
> >>>>Nikos
> >>>>
> >>>>Don wrote:
> >>>>
> >>>>
> >>>>>Hello,
> >>>>>
> >>>>>This is the fourth time i have put this on here, please can someone help me,
> >>>>>i am desperate now, this is for my project. everybody i know can not do this !
> >>>>>
> >>>>>I have employees that can have up to three different expertise and orders
> >>>>>that can also have three different requirements. all requirements and
> >>>>>expertise are stored on individual fields eg if employee has 2 expertise, it
> >>>>>is stored as follows: -
> >>>>>
> >>>>>employee id SkillId
> >>>>>1 1
> >>>>>1 2
> >>>>>2 1
> >>>>>2 2
> >>>>>2 3
> >>>>>
> >>>>>the order requirements are stored: -
> >>>>>
> >>>>>Order ID SkillId
> >>>>>1 1
> >>>>>1 2
> >>>>>1 3
> >>>>>2 1
> >>>>>2 2
> >>>>>
> >>>>>in the above case only employee 2 can do order 1 but both employee 1 and 2
> >>>>>can carry out order 2
> >>>>>
> >>>>>I have put put skill tables in the same query and matched the skill id but
> >>>>>this retrieves all employees that can do every skill. i have tried to group
> >>>>>them but i can not do this either ?
> >>>>>
> >>>>>Please can some one help ?
> >>>>
>



Relevant Pages

  • Re: multi table multi database join?
    ... dont i have some kind of filter? ... sybase runns on one machine mssql on another, ... the data from the aggregate db could be used in a query to ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Stupid Query Question...Column Display
    ... Looking at this reply a bit closer, I see that you mention a filter to not ... In your Query, I expect that you specified conditions in which you ... that might very well produce an empty recordset. ... If employee has done Job 'X' then just show that column and not the other 14 ...
    (microsoft.public.access.queries)
  • Re: Oracle Merge Statement -sample query
    ... On May 21, 5:31 pm, Frank van Bortel ... USING (SELECT D.ID, D.NAME, D.SALARY FROM employee D ... --without preidicate filter in using ... Kindly point out if i have written the query wrong:) ...
    (comp.databases.oracle.misc)
  • Re: How to look for a specific data in a table???
    ... I have a data list in 1 of my tables and I would like to look for a specific record in that list for example, by entering an unique field (Employee ID) in the table; instead of using the navigation buttons in the form or select the data using combo box. ... Drag the Emp ID field into the query and set the criteria as "[What employee number please? ... Now create a macro with Action ApplyFilter. ... In the Filter Name parameter type the name of the query you just saved. ...
    (microsoft.public.access.queries)
  • Form, Query, and Updating Records
    ... I have an employee profile form that I would like to filter by what ... The location value is stored in a Query. ...
    (microsoft.public.access.formscoding)