Results 1 to 8 of 8
  1. #1
    nparrillo is offline Novice
    Windows XP Access 2007
    Join Date
    Apr 2011
    Posts
    14

    Please help Query IIFs

    Folks,
    I hope this makes sense.

    I have these two tables, items within each table are linked by a registration number. Within table 1, I have a top stage value and a base stage value all of which is accompanied yes by a corresponding stage number.

    The second table, contains a top point value and a base point value. I want to see if it possible to run a query to see if the top point and base point values fall within the span of the the top stage and base stage values, and if so, yield the respective corresponding stage number that that accompanies the stage values.

    Let me know what you all think..

    The end goal by generating the stage number value that is in the first table within the second table would be that I could then be able to build a relationship between the two tables using the stage numbers.

  2. #2
    kennejd is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Mar 2011
    Posts
    188
    You will create a query....join the tables by registration number. Use a between comparison in the criteria to find your ranges. Sorry my answer is a little vague...I'm having trouble following your question...

  3. #3
    nparrillo is offline Novice
    Windows XP Access 2007
    Join Date
    Apr 2011
    Posts
    14
    yes, the tables are joined by registration number. maybe the formula I have attemped to write will help you follow.

    Stage Number Match:IIF([Points]![Depth Top]<=[Stages)]![Depth Top] And IFF([Points)]![Depth Base]>=[Stages]![Depth Base],[Stages)]![StageNumber]))

  4. #4
    nparrillo is offline Novice
    Windows XP Access 2007
    Join Date
    Apr 2011
    Posts
    14

    Sample File

    See file this might clear some things up

  5. #5
    kennejd is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Mar 2011
    Posts
    188
    Try this:
    Stage Number Match:IIF([Points]![Depth Top]<=[Stages)]![Depth Top] And [Points)]![Depth Base]>=[Stages]![Depth Base],[Stages)]![StageNumber])

  6. #6
    nparrillo is offline Novice
    Windows XP Access 2007
    Join Date
    Apr 2011
    Posts
    14
    that didnt seem to work either. see the file i attached it might help you under stand what I am talking about. I really apprieciate your help.

  7. #7
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    Both TopPoint and BasePoint need to be included in the same range? See if this does what you want (if they aren't both between, it should return 0):

    SELECT Points.RegNumber, Points.TopPoint, Points.BasePoint, Nz(STAGES.StageNumber,0) AS StageNum
    FROM Points LEFT JOIN STAGES ON (Points.TopPoint >= STAGES.TopStage AND Points.TopPoint <= STAGES.BaseStage) AND (Points.BasePoint >= STAGES.TopStage AND Points.BasePoint <= STAGES.BaseStage) AND (Points.RegNumber = STAGES.RegNumber)
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  8. #8
    kennejd is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Mar 2011
    Posts
    188
    The formula should look like:

    StageMatch: IIf([TopPoint] Between [TopStage] And [BaseStage] AND [BasePoint] Between [TopStage] And [BaseStage],[StageNumber])

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

Similar Threads

  1. IIfs, likes, and calculated fields
    By chilly hellion in forum Queries
    Replies: 0
    Last Post: 03-29-2011, 11:41 AM
  2. Multiple IIfs
    By SueO in forum Reports
    Replies: 1
    Last Post: 08-12-2010, 04:53 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