Results 1 to 5 of 5
  1. #1
    Join Date
    Jun 2011
    Location
    Sault Ste. Marie, Ontario, Canada
    Posts
    28

    Help with complex 'IF' function(s) ...

    Even thought I AM Captain Database ... (!!) Fighter of the ~EviL~ data error ... (!!) ... ehemm, I am not toooo familiar with Access 'IF' functions. How would I write the following in Access (copied from another freebie datasoft')?



    Test1:
    IF ([GR_GT_collees] <> -99 AND [GR_GT_abimees] <> -99) THEN [GR_GT_collees] + [GR_GT_abimees] must be 0< and <300 ELSE [GR_Saines] + [GR_Parasitees] + [GT_Vides] must be 0< and <300

    Test2:
    IF ([GR_GT_collees] <> -99 AND [GR_GT_abimees] <> -99) THEN [GR_GT_collees] + [GR_GT_abimees] + [GR_PT] must be 0< and <400 ELSE [GR_Saines] + [GR_Parasitees] + [GT_Vides] + [GR_PT] must be 0< and <400

    Test3:
    IF ([GR_GT_collees] <> -99) THEN [GR_Gaines] + [GR_Vides] + [GR_Parasitees] must equal [GR_GT_collees]

    Test4:
    IF ([Tree] <> -99 AND [Cone] <> -99) THEN [Operation] x 10,000,000 + [Stand] x 10,000 + [Tree] x 100 + [Cone] must equal a distinct integer

  2. #2
    khalid's Avatar
    khalid is offline MS-Access Developer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2010
    Location
    Kuwait
    Posts
    244
    Did you try to use the IIF() function?

  3. #3
    Join Date
    Jun 2011
    Location
    Sault Ste. Marie, Ontario, Canada
    Posts
    28
    I am trying to use the IIF function, but am a little unsure of how to write it. Can all of these conditions be put into one? How would I write test 1, for instance? This is my attempt so far, although it is rejected:

    IIF([GR_GT_collees]=-99 AND [GR_GT_abimees]=-99, ([GR_GT_collees]+[GR_GT_abimees]) 0< AND <300 ELSE ([GR_Saines]+[GR_Parasitees]+[GT_Vides]) 0< and <300


  4. #4
    Join Date
    Jun 2011
    Location
    Sault Ste. Marie, Ontario, Canada
    Posts
    28
    I've actually managed to achieve the results I wanted by splitting the specific "if" condition, and the required/associated ranges, between two separate field-criteria. 'Can' such a complex function be entered into 'one' field, however, or is breaking it down into several, simpler fields the way to go? e.g., test1 as split between two separate fields/criteria;

    =field1= tests_IIf(i): IIf([GR_GT_collees] And [GR_GT_abimees]<>-99,1,0)
    =criteria= 1

    =field2= ([GR_Saines]+[GR_Parasitees]+[GR_Vides])
    =criteria = >0 and <300

  5. #5
    boblarson is offline --------
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1,272
    This would be the correct usage (If I understand your request):


    IIF([GR_GT_collees] <> -99 AND [GR_GT_abimees] <> -99, IIf(Nz([GR_GT_collees],0)+Nz([GR_GT_abimees],0) > 0 AND Nz([GR_GT_collees],0)+Nz([GR_GT_abimees],0) <300, Nz([GR_GT_collees],0)+Nz([GR_GT_abimees],0), 0))

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

Similar Threads

  1. Too Complex to be evaluated - HELP!
    By awmmoore in forum Queries
    Replies: 2
    Last Post: 06-06-2011, 10:23 AM
  2. Complex Criteria
    By Kapelluschsa in forum Queries
    Replies: 7
    Last Post: 05-23-2011, 03:45 PM
  3. Help with complex Query
    By CEV in forum Queries
    Replies: 1
    Last Post: 03-12-2011, 06:54 AM
  4. Duplicate query with complex delete function
    By rushforth in forum Queries
    Replies: 9
    Last Post: 08-20-2010, 01:21 AM
  5. Complex Lookup?
    By murphyB in forum Database Design
    Replies: 1
    Last Post: 09-17-2009, 12:43 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