Results 1 to 2 of 2
  1. #1
    sudEMS is offline Novice
    Windows XP Access 2007
    Join Date
    Dec 2012
    Posts
    1

    Two tables: Use 2 critiera to look up value

    There are two tables:



    Table 1

    - UnitID
    - StartDateTime
    - EndDateTime
    - CallNumber

    Table 2

    - VehicleID
    - DateTimeStamp


    What we need is to run a query that will return the following fields

    - VehicleID
    - DateTimeStamp
    - CallNumber

    Where:

    - UnitID and VehicleID are equal
    - DateTimeStamp from Table 2 is greater than the Start time in Table 1 and less than the End time in Table 1.

    So without a relationship between the two tables how do we proceed?

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Assuming the ID fields are number type, try:

    SELECT VehicleID, DateTimeStamp, DLookup("CallNumber", "Table1", "UnitID=" & VehicleID & " AND #" & DateTimeStamp & "# BETWEEN StartDateTime AND EndDateTime") As CallNumber;
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Replies: 5
    Last Post: 12-14-2012, 04:21 PM
  2. Dynamic Query Critiera: Form Name
    By tylerg11 in forum Forms
    Replies: 1
    Last Post: 06-25-2012, 11:27 AM
  3. Replies: 1
    Last Post: 12-15-2011, 04:26 AM
  4. Replies: 10
    Last Post: 07-12-2011, 11:09 PM
  5. Joining tables two tables and another table that is not
    By DevintheDude in forum Database Design
    Replies: 0
    Last Post: 09-12-2007, 08:56 AM

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