Results 1 to 2 of 2
  1. #1
    toonarmy is offline Novice
    Windows XP Access 2010 64bit
    Join Date
    Nov 2012
    Posts
    1

    Take Query Inputs From a Table

    Hi everyone,



    First post from a newbie. The query below works if I run it as a select query when I enter values direct, but I don't know how to take those same inputs from another table.

    Here's the query:-

    SELECT wkts3.Winner, Count(wkts3.Winner) AS CountOfWinner
    FROM wkts3
    WHERE (((wkts3.RunDiff)>10 And (wkts3.RunDiff)<30))
    GROUP BY wkts3.Winner, wkts3.Inns, wkts3.Team1Wkts, wkts3.Team2Wkts
    HAVING (((wkts3.Inns)=1) AND ((wkts3.Team1Wkts)=19));

    If you're interested, what this does is take the current state of a cricket match and find the likelihood of the home ("Team1") or away ("Team2") team winning, or the match ending in a draw ("Drawn") - that information is shown in the field Winner of the table wkts3. RunDiff is the difference in total runs scored by each team, the innings (Inns) is either 1, 2, 3 or 4, and the final input is either Team1Wkts or Team2Wkts depending on which team is batting, and is always a number between 0 and 20.

    Running this query with those values in the query above will give me a list which will look something like this:-

    Team1 85
    Team2 76
    Drawn 73

    So basically the query finds all of the the matches in wkts3 which had the same state, or very close, in terms of Innings, RunDiff and Team1Wkts/Team2Wkts, and counts how many resulted in a win for Team1, Team2 or were drawn. What I would like to do is take the inputs for the query from another table, InState. So for a particular record in InState, which will have a value in each record for the fields Inns, RunDiff and either Team1Wkts or Team2Wkts (one will have a value between 0 and 20, the other will be a null), take those values as inputs to the query and generate the same results as above.

    I presume I need to change the query type and/or make a relationship between the two tables, but trial and error hasn't shown me the solution.

    If I haven't explained this well enough please let me know - hopefully there's enough without requiring a knowledge of cricket!

    Thanks,

    Dave

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    Not understanding data structure. Can't even tell if these tables have a relationship. Since there is a wkts3 table is there also wkts1, wkts2, etc? If you want to provide database for analysis, follow instructions at bottom of my post.
    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: 18
    Last Post: 10-10-2012, 10:10 AM
  2. Using user inputs as variables in a query/report?
    By cheese9799 in forum Reports
    Replies: 3
    Last Post: 03-01-2011, 11:30 AM
  3. selecting Sub-Form data from two inputs
    By techexpressinc in forum Queries
    Replies: 19
    Last Post: 12-03-2010, 11:03 AM
  4. Replies: 1
    Last Post: 11-30-2009, 05:11 PM
  5. Multiple inputs one result
    By ee12csvt in forum Queries
    Replies: 0
    Last Post: 09-11-2009, 03:19 AM

Tags for this Thread

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