Results 1 to 4 of 4
  1. #1
    imintrouble is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2011
    Location
    Missouri, where frownin's a sport
    Posts
    127

    Giant If statement?

    Hello once again kind people of Microsoft Access Forums!

    I am in need help with this current project I have. What it is supposed to do is take the number from four seperate fields in my query, checking them like this

    if AGShrs = 0 then
    if ASBAhrs = 0 then
    Degree = ASBA
    else if ASCJhrs = 0 then
    Degree = ASCJ
    else if AAhrs = 0 then
    Degree = AA
    else
    Degree = Potential
    Endif


    I understand that this is in no way correct syntax but i haven't done vb in a while so as you can understand, i'm a bit rusty. Now let me explain this formula a bit.

    the first thing it needs to check is if the hrs of the AGS field are 0. If they are it then checks both ASBA and then ASCJ. If either are 0, then degree will be equal to the one that is 0. If it isn't but AGS was 0, then degree = AGS. Then it finally checks if AA was 0, making degree AA if it was. Lastly if none were 0, degree needs to be marked as potential. The answers of all of this, what degree is set to equal as in the end of the code, needs to be input into the field which this module will reside.



    Thanks!

  2. #2
    dreday's Avatar
    dreday is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Aug 2011
    Posts
    58
    I think this will work for you

    if ((AGShrs = 0) AND (AGShrs=0)) then
    Degree = "ASBA"
    elseif (ASCJhrs=0) then
    Degree = "ASCJ"
    elseif (AAhrs=0) then
    Degree = "AA"
    else
    Degree = "Potential"
    end if

  3. #3
    hertfordkc is offline 18 year novice
    Windows XP Access 2007
    Join Date
    Mar 2011
    Posts
    481

    I believe that you need a calculated field in your query.

    Quote Originally Posted by imintrouble View Post
    Hello once again kind people of Microsoft Access Forums!

    I am in need help with this current project I have. What it is supposed to do is take the number from four seperate fields in my query, checking them like this

    if AGShrs = 0 then
    if ASBAhrs = 0 then
    Degree = ASBA
    else if ASCJhrs = 0 then
    Degree = ASCJ
    else if AAhrs = 0 then
    Degree = AA
    else
    Degree = Potential
    Endif


    I understand that this is in no way correct syntax but i haven't done vb in a while so as you can understand, i'm a bit rusty. Now let me explain this formula a bit.

    the first thing it needs to check is if the hrs of the AGS field are 0. If they are it then checks both ASBA and then ASCJ. If either are 0, then degree will be equal to the one that is 0. If it isn't but AGS was 0, then degree = AGS. Then it finally checks if AA was 0, making degree AA if it was. Lastly if none were 0, degree needs to be marked as potential. The answers of all of this, what degree is set to equal as in the end of the code, needs to be input into the field which this module will reside.

    Thanks!
    -------------------------------------------------------------------------
    Degree:iif(AGShrs = 0,iif(ASBAhrs = 0,"ASBA",iif(ASCJhrs = 0,"ASCJ",iif(AAhrs = 0,"AA","")),"Potential")

    Note that there is a path here where I put an empty string. Perhaps the empty string and "Potential" need to be swapped. I hope the parens are balanced so you can test it to see if it delivers the desired result.

  4. #4
    imintrouble is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2011
    Location
    Missouri, where frownin's a sport
    Posts
    127
    Thanks to both of you. I had already started trying the top answer when I saw you comment hertfordkc but I got it all to work out nicely. Had to mess with some access magic but otherwise succeeded. Thanks to both of you, and enjoy the extra rep >.<

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

Similar Threads

  1. Replies: 7
    Last Post: 08-17-2011, 01:49 PM
  2. IIF statement
    By LilMissAttack in forum Queries
    Replies: 2
    Last Post: 08-05-2011, 08:49 AM
  3. if-then statement in vba
    By rivereridanus in forum Programming
    Replies: 3
    Last Post: 07-07-2011, 02:11 PM
  4. BETWEEN in a FROM Statement
    By Cyborg in forum Queries
    Replies: 6
    Last Post: 05-12-2011, 01:54 PM
  5. how to use IF then statement
    By ronnie4 in forum Access
    Replies: 1
    Last Post: 03-17-2009, 11:32 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