Results 1 to 5 of 5
  1. #1
    sarsmelt is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2014
    Posts
    17

    select top queries

    I've been trying to use a select top query to have access choose the next closest date and time from the list. Basically I want to know the difference between the end of shift 1 and the beginning of shift 2.



    I'm having a hard time getting access to choose the correct record for the beginning of shift 2 because my IDs correlate to multiple different queries.

    What's happening is that it doesn't like when I want to find the difference between shift 1 and shift 4 for example.

    Here's a picture of my database
    Click image for larger version. 

Name:	CaptureDesign.PNG 
Views:	11 
Size:	10.7 KB 
ID:	18767
    Click image for larger version. 

Name:	CaptureRun.PNG 
Views:	11 
Size:	46.9 KB 
ID:	18766


    Each Expr1 should be the next ID's Power_On and each Expr2 should be the next ID's Start_Pour but it's pulling from further down.

    I'm not sure what's going wrong.

    Thanks, Sarah

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,850
    Could you give us some context surrounding your database and issue? Something along the lines of
    "a day in the life of our business" - just so we understand the issue better.

    I see 1 table only -- that is somewhat rare for database.

    Can you tell us in plain English exactly what you wanted this query to do?

    Could you take a few records and show us WHAT the "correct output" should be?

    Can you post the SQL for the query you have posted?

  3. #3
    sarsmelt is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2014
    Posts
    17
    are melting metal to make into powder as I understand it (I'm not too involved in the actual process just an intern assigned to making this database).

    Yes there are quite a few more tables in this database. This is actually just a query but the rest don't pertain to my specific question.

    The rest of the entries in this query are correct. IE: ID 8 Expr1 should pull the 11/5 2:25 AM that it has pulled from ID 17 Power_On and Expr2 should pull 11/5 3:46 AM that it's pulled from ID 17.

    My issue is that on some of them, like IDs 5, 6, and 7, are pulling from an ID further down, ID 8 in this case when the should be pulling from IDs 6, 7, and 8 respectively.

    Does this help?

  4. #4
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    I agree with Orange.... need more info about your query(s) and dB design.

    However, looking at what you provided, I would design the table differently. IMO, the design of the table is in classic "spreadsheet" design - short and fat.
    I would design it tall and narrow:

    Code:
    ID (PK - Autonumber - actually a poor name)
    EventAction_FK (Long)     << - What happened / FK to table EventAction
    Shift (Integer)
    FurnaceNum (Integer - NO spaces in name)
    EventDateTime (Date/Time)   << - when it happened
    The EventAction table:
    Code:
    tblEventAction
    ---------------
    EA_ID (PK - autonumber)
    EventActionDesc (Text)
    
    Data Desc would be:
    1 Power On
    2 Start Pour
    3 End Pour
    Then it is relatively easy to get the date/time for the end of shift 1 and the beginning of shift 2, depending on what you define as the end of a shift and the start of another.



    My $0.02 ..........

  5. #5
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,850
    sarsmelt,

    I agree with Steve based on the info. You really don't work on part of a database , or one table out of many.
    If you are new to database design, here's some info that may help put things perspective.

    Good luck with your project.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. User select queries
    By jcrump230 in forum Queries
    Replies: 15
    Last Post: 07-14-2014, 10:03 AM
  2. Replies: 5
    Last Post: 05-14-2014, 01:17 PM
  3. Novice Needs Help With Simple Select Queries
    By GAtkins in forum Queries
    Replies: 5
    Last Post: 11-26-2013, 04:36 PM
  4. Queries to select MAX
    By johnseito in forum Queries
    Replies: 20
    Last Post: 09-15-2013, 07:13 AM
  5. Queries based on a Select Case
    By dccjr in forum Queries
    Replies: 3
    Last Post: 03-05-2013, 04:12 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums