Results 1 to 4 of 4
  1. #1
    Ian Frost is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2014
    Posts
    11

    Add an additional Variant to the iif statment

    Below is the code for determining the Point of Contact on a project during a specific status of the project (Planning, Design, Construction). Once the status of the project is in construction "10" the POC is role3 - Project Manager. My issue is with 4 - Planning and 8 - Design. When the project is in planning the POC is role1 - Planner and in design the POC is role2 - Architect in Charge. The issue is that some projects in Planning or Design do not have a POC related to the status, in that instance I want the POC to be role3 - Project Manager. I have highlighted the two code lines that I am having problems with.

    Thank You for your help.

    Function PointOfContact(mproject, mstatus, mtype)
    ' mproject = fp&d project #
    ' mstatus = project status
    ' mtype = project type
    Dim mpoc As Variant, role1 As Variant, role2 As Variant, role3 As Variant
    mpoc = Null
    role1 = "Planner"
    role2 = "Architect in Charge"
    role3 = "Project Manager"
    role4 = "FPD Rep"

    Select Case mstatus

    Case Is = 1


    mpoc = DLookup("[member name]", "team_members_with_roles", "[fp&d project #] = " & Chr(34) & mproject & Chr(34) & " and [role] = " & Chr(34) & role3 & Chr(34))
    'mpoc = IIf(Not IsNull(mpoc), mpoc & ", " & role3, "")

    Case Is = 4
    mpoc = DLookup("[member name]", "team_members_with_roles", "[fp&d project #] = " & Chr(34) & mproject & Chr(34) & " and [role] = " & Chr(34) & role1 & Chr(34))
    'mpoc = IIf(Not IsNull(mpoc), mpoc & ", " & role1, "")

    Case Is = 8
    mpoc = DLookup("[member name]", "team_members_with_roles", "[fp&d project #] = " & Chr(34) & mproject & Chr(34) & " and [role] = " & Chr(34) & role2 & Chr(34))
    'mpoc = IIf(Not IsNull(mpoc), mpoc & ", " & role2, "")

    Case Is = 10
    mpoc = DLookup("[member name]", "team_members_with_roles", "[fp&d project #] = " & Chr(34) & mproject & Chr(34) & " and [role] = " & Chr(34) & role3 & Chr(34))
    'mpoc = IIf(Not IsNull(mpoc), mpoc & ", " & role3, "")

  2. #2
    CJ_London is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    Something like this?

    Code:
    Case Is = 4
    mpoc = DLookup("[member name]", "team_members_with_roles", "[fp&d project #] = " & Chr(34) & mproject & Chr(34) & " and [role] = " & Chr(34) & role1 & Chr(34))
    if isnull(mpoc) then mpoc = DLookup("[member name]", "team_members_with_roles", "[fp&d project #] = " & Chr(34) & mproject & Chr(34) & " and [role] = " & Chr(34) & role3 & Chr(34))
    

  3. #3
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    1. you CAN use single quotes and it is easier to read:
    mpoc = "[fp&d project #] = ' " & mproject & " ' and [role] = ' " role1 & " ' ") ' no spaces around quotes, these are for readability

    2. note , params usually get the prefix p, as parameter inside the function, so they dont confuse with modular variables m.
    Function PointOfContact(pProject, pStatus, pType)

  4. #4
    Ian Frost is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2014
    Posts
    11
    Ajax, Thanks the code works perfect.

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

Similar Threads

  1. Replies: 8
    Last Post: 08-17-2023, 02:33 AM
  2. Replies: 6
    Last Post: 11-16-2013, 06:06 PM
  3. if statment or case statment?
    By whojstall11 in forum Forms
    Replies: 4
    Last Post: 07-09-2012, 01:44 PM
  4. Converting Variant Listbox Results
    By dreamnauta in forum Programming
    Replies: 4
    Last Post: 01-03-2012, 12:24 PM
  5. Replies: 2
    Last Post: 09-27-2010, 02:17 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