Results 1 to 5 of 5
  1. #1
    MFS is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2009
    Location
    Ohio
    Posts
    235

    Multiple Tables, One Query

    I have numerous tables with similar information.
    Example:


    Table one has the following information . . . .
    Device 1
    Time
    Date
    Temperature

    Table two has the following information . . . .
    Device 2
    Time
    Date
    Temperature

    Table three has the following information . . . .
    Device 3
    Time
    Date
    Temperature

    I have a few text boxes within the form that controls the criteria information for my chart. I do not know how to populate my chart with the data From Table 3, AKA Device 3 table, Or Table two, since my chart's 'Row Source' is predefined.

    Any help would be appreciated.

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    union query:

    sql =
    select * from tbl1
    union
    select * from tbl2
    union
    select * from tbl3

  3. #3
    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
    Why not 1 table with another field for DeviceID? This is essentially the output of UNION query. Would expand the UNION query to include device identifier as a calculated field: "1" AS DeviceID. Also, using the * field wildcard assumes fields are all in the same order in the table design. There is no wizard or designer for UNION, must type in SQL View of query builder. Limit of 50 SELECT lines.

    Darn, it's happening again - forum won't let me type UNION in the query example.

    SELECT *, "1" AS DeviceID FROM tbl1
    ______ SELECT *, "2" FROM tbl2
    ______ SELECT *, "3" FROM tbl3;
    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.

  4. #4
    MFS is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2009
    Location
    Ohio
    Posts
    235
    June7,
    The reason I have multiple tables is because I have a PLC sending data to my SQL DB. When an output goes high on the PLC the DB knows to pull defined tags of data into the database dependent on which trigger/output is high. I don't always want all the data for each device every time the trigger goes high so I use multiple triggers, one for each Device. Which would require one table for each device. (Whewwww, that is hard to explain)
    I just completed ranman256's suggestion and it works perfectly. I created a Union Query and then a simple Query where I wrote my criteria using text boxes from my form.
    Thanks June7 and ranman256 for your help.
    I'm going to leave this post open until I return to work tomorrow morning. After I review that all is working well I will mark as solved.

  5. #5
    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
    A UNION will not allow duplicate records which means if any records in one table are identical to records in another table, only one shows. Use calculated identifier field and/or UNION ALL.
    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: 1
    Last Post: 04-12-2013, 03:03 PM
  2. Replies: 3
    Last Post: 01-05-2012, 12:04 PM
  3. Query Multiple Tables
    By Tomfernandez1 in forum Queries
    Replies: 1
    Last Post: 02-04-2011, 09:31 PM
  4. Can I query multiple tables
    By Sarge, USMC in forum Queries
    Replies: 2
    Last Post: 10-28-2010, 09:54 PM
  5. Query from multiple tables
    By ambidextor in forum Queries
    Replies: 1
    Last Post: 02-25-2010, 08:01 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