+ Reply to Thread
Results 1 to 3 of 3

Query is skipping values

  1. #1
    Forum Contributor
    Join Date
    02-25-2008
    Location
    Windsor, ON Canada
    MS-Off Ver
    Excel 2007, 2003
    Posts
    119

    Query is skipping values

    Hi,

    I have a simple query.

    It pulls production hours, by employee number, by week. However, if for whatever reason an employee gets missed by production, I need the hours for that employee to show up as 'zero' for that week, instead of not listing the week at all.

    To accomplish this I setup a table that lists every employee number by every week. In my query I create a relationship between the production data and the table listing the weeks (read: I've joined the 'WEEK' field between each) hoping to have the following result:

    Wk 35 Emp #1 40 hours
    Wk 36 Emp #1 45 hours

    Instead I'm still only getting Wk 35 showing up.

    What could be causing this miss? What can I provide for you to better understand my issue? (new to Access, not sure what you need to see).

    Thanks

  2. #2
    Forum Contributor
    Join Date
    02-25-2008
    Location
    Windsor, ON Canada
    MS-Off Ver
    Excel 2007, 2003
    Posts
    119

    Re: Query is skipping values

    Posting the SQL view. Note that "PERNR" is the employee number.

    SELECT [SM EE Direct Hours].PERNR, WK01.WEEK, Sum([SM EE Direct Hours].HOURS) AS SumOfHOURS
    FROM WK01 LEFT JOIN [SM EE Direct Hours] ON WK01.WEEK = [SM EE Direct Hours].WEEK
    GROUP BY [SM EE Direct Hours].PERNR, WK01.WEEK;

  3. #3
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: Query is skipping values

    I believe you should set up your database with three tables: an employee table, a week table (this one would be quite simple), and a table that holds the hourly data. The employee ID should be the primary key in the employee table, the week ID should be the primary key in the Week table, and the hourly table should have a generic ID. All hourly data should be kept in the Hourly table.

    Can you post sample database?
    Is your code running too slowly?
    Does your workbook or database have a bunch of duplicate pieces of data?
    Have a look at this article to learn the best ways to set up your projects.
    It will save both time and effort in the long run!


    Dave

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1