Results 1 to 4 of 4
  1. #1
    jetman5843 is offline Novice
    Windows XP Access 2003
    Join Date
    Apr 2014
    Posts
    2

    Query pulling data from multiple tables

    Hi All:



    I'm new to this forum and am hoping I can get some help on this issue.

    I am making a query on customer orders. We use header and detail tables to store order data in.

    I have 4 tables I need to query on. We have current open orders tables (header table and detail table) and completed orders tables (header and detail table). The key field in each of the 4 tables are order number. Each set of tables are joined by this field.

    When an order is placed, the data is stored in the current order header table for certain information such as customer number, address, date entered, total order value, etc... The line item detail of the order such as the material, description, item cost , etc. is stored in the current order detail table.

    As the order is built and items from orders are shipped, the line items are deleted from the current open order Line item table and stored in the order line item history table. when the order is totally complete, the header table entry is deleted and stored in the header history table.

    My issue is being able to query both sets of tables for data on orders based on date range selection criteria.

    Does anyone have a way to be able to do this?

    Regards.
    Kevin

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    The issue is using 'history' tables. I would not do this. I would have a field in detail table for ship date and use that field to determine if order is complete. Instead of 'moving' records I would apply filter criteria.

    Otherwise, use a UNION query to recombine the records to one dataset and search that query.
    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.

  3. #3
    jetman5843 is offline Novice
    Windows XP Access 2003
    Join Date
    Apr 2014
    Posts
    2
    Thanks for the reply June7:

    Unfortunately, the database i'm using is made up of tables that are linked into our Access database from our ERP system and that is how the system stores order data.

    Can you point me in the rgiht direction for a little information on union queries? Can I use that for the situation i described above?

    Regards,
    Kevin

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    There is no wizard or builder for UNION. Must type or copy/paste into SQL view of query designer. There is a limit of 50 SELECT lines. The syntax is like:

    SELECT field1, field2, field3 FROM table1
    UNION SELECT field1, field2, field3 FROM table2;

    Search web on topic, lots of info. Here is one http://www.w3schools.com/sql/sql_union.asp
    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. Pulling from Multiple Tables in VB
    By Canadiangal in forum Programming
    Replies: 12
    Last Post: 04-04-2013, 10:20 PM
  2. Replies: 5
    Last Post: 12-27-2012, 02:54 PM
  3. Replies: 2
    Last Post: 03-29-2012, 04:03 AM
  4. Have 3 tables - problem with pulling data for query
    By wulfhund in forum Database Design
    Replies: 2
    Last Post: 08-13-2010, 05:38 AM
  5. Pulling only certain data from tables.
    By stevman22889 in forum Access
    Replies: 2
    Last Post: 07-15-2010, 06:23 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