Results 1 to 3 of 3
  1. #1
    ATTHECROSS is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Oct 2017
    Posts
    14

    Need help with vba for if else statement for three values: Completed, in progress & not started

    Hello All -



    I need a VBA code where Column "A" has three variables: Completed, In Progress & Not Started. Based upon the variable I need Column "B" to show a "3" for "Completed", a "2" for "In Progress" and a "1" for "Not Started." I am new to VBA and very new to If Else statements so I appreciate everyones help. I would like to run this in Access as part of a report output, but is that even possible or do I just need to run the VBA in excel once I have queried the data in Access and dumped it into excel?

    Thanks in advance for the help!

  2. #2
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    You can use the MS Access switch function:

    Column_B = switch([Column_A] = "Completed",3, [Column_A] = "In Progress", 2, [column_A] = "Not Started", 1)

    The function returns a Null if [Column_A] is not one of those three values.

  3. #3
    ATTHECROSS is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Oct 2017
    Posts
    14
    John_G

    Thank you for your time! That worked perfectly! Happy New Year

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

Similar Threads

  1. If statement comparing 2 values
    By Ekhart in forum Programming
    Replies: 3
    Last Post: 09-15-2016, 11:16 AM
  2. Replies: 6
    Last Post: 11-21-2015, 09:52 AM
  3. Where to get started
    By cowmoogun in forum Programming
    Replies: 12
    Last Post: 01-03-2013, 07:44 PM
  4. Please help get me started
    By jwalter007 in forum Database Design
    Replies: 4
    Last Post: 08-25-2012, 04:32 AM
  5. how to get started
    By scottsoo9 in forum Access
    Replies: 1
    Last Post: 11-18-2009, 04:13 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