Results 1 to 3 of 3
  1. #1
    nyquilx is offline Novice
    Windows 7 Access 2007
    Join Date
    May 2010
    Posts
    1

    Use result of one query for criteria of another

    Good morning everyone,



    I have one table
    iadjustments / dDate / iRepID
    .3 1/1/10 9000
    .2 1/1/10 9000

    (SELECT Sum(tblcalladjustments.tTimeadjusted) AS SumOftTimeadjusted FROM tblcalladjustments WHERE (((tblcalladjustments.ddate)=[Enter Date]) AND ((tblcalladjustments.iagentID)=[Enter Rep])) AS Adjustments

    Second Query

    SELECT [tblagentcallstats]![iavail]+[tblagentcallstats]![italkavail]+[tblagentcallstats]![iovfl]+[tblagentcallstats]![iagentovfl]+[tblagentcallstats]![ientper]+[tblagentcallstats]![iintper]+[tblagentcallstats]![Iextper]+[tblagentcallstats]![iintper2]+[tblagentcallstats]![iotherper] AS [Total Avail %]
    FROM tblagentcallstats
    WHERE (((tblagentcallstats.ddate)=[Enter Date]) AND ((tblagentcallstats.iagentid)=[Enter Rep]));

    Now i need to combine them

    [Total Avail %] - [Adjustments] AS Actual

    Any ideas?

  2. #2
    Robertt is offline Novice
    Windows 7 Access 2007
    Join Date
    May 2010
    Posts
    12
    Start by adding your primary key(s) to the select statement of each of your two queries. Next join them on the primary keys you added above. I.e.


    select * from (select pk1, pk2 ... first query) q1
    right join (select pk1, pk2,... second query) q2
    on q1.pk1=q2.pk1 and q1.pk2=q2.pk2.

    Next adjust the "select *" portion to include your formula that subtracts your to calculated values

    HTH,

    Robert

  3. #3
    TheShabz is offline Court Jester
    Windows XP Access 2003
    Join Date
    Feb 2010
    Posts
    1,368
    NEVERMIND!!! I noticed those are all calculated fields. My apologies. I'll leave the comment below anyway for anyone it may benefit


    Also, I'd suggest using & as your concatenator instead of +. + works fine if they are all strings but if you get a number field thrown in there, it can mess things up. It will actually add them together instead of putting them together.

    example
    11+11=22
    11&11=1111

    by convention most people I know use & always.
    Last edited by TheShabz; 05-18-2010 at 01:44 PM. Reason: I'm stupid =]

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

Similar Threads

  1. If Query result Is Null...MsgBox..Okl
    By Bruce in forum Forms
    Replies: 28
    Last Post: 03-10-2010, 10:57 AM
  2. Query result based upon two field conditions
    By diane802 in forum Access
    Replies: 35
    Last Post: 01-08-2010, 06:31 PM
  3. How do I determine a SQL query result?
    By Trainman in forum Database Design
    Replies: 1
    Last Post: 10-15-2009, 04:49 AM
  4. Result of Count Query not known elsewhere
    By Carole in forum Access
    Replies: 1
    Last Post: 09-07-2008, 09:39 AM
  5. Replies: 2
    Last Post: 08-04-2008, 04:16 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