Results 1 to 4 of 4
  1. #1
    AndycompanyZ is offline Advanced Beginner
    Windows Vista Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    80

    IIf and dlookup syntax

    I am trying to build a iif statement based on a dlookup to populate a filed on a form. So far I have:


    Code:
     
    = IIf((DLookUp( "[SubTeamHeadDelID]" ,"[tblSubTeam]","[Me]![SubTeamHeadDelID] =" &  [DelegateID]), [tblSubTeam]![SubTeamParentID] , [tblSubTeam]![SubTeamHeadDelID]))
    But this gives an error that there are the wrong number of arguments. What I am trying to do is see firstly if the SubTeamHeadDelID is the same as the DelegateID on the form if so then put the SubTeamParentID into the box and if not put the SubTeamHeadDelID in the box. I have never combined a dlookup with an iif statement so I don't know even if this the correct way of doing it or even if it's possible. Any help would be most helpful thanks.

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,610
    Hi
    put the SubTeamParentID into the box and if not put the SubTeamHeadDelID in the box
    Where are the true and false values (in blue). Are they on the Form, or are fields in a table called "[tblSubTeam]".
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    AndycompanyZ is offline Advanced Beginner
    Windows Vista Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    80
    They are on both actually. What I ultimately need to do is find the Ids and then have another textbox which will show the mobilenumber (which is stored on a delegate table) of the person to contact whether it belongs to SubTeamParentID or the SubTeamHeadDelID.

  4. #4
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,610
    Hi

    I'm not sure that this is what you need.
    Please try it and post back with results.

    = IIf((DLookUp("[SubTeamHeadDelID]" ,"[tblSubTeam]","[DelegateID] =" & Me]![SubTeamHeadDelID]), Me.[SubTeamParentID], Me.SubTeamHeadDelID]))
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

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

Similar Threads

  1. SQL syntax
    By jgelpi16 in forum Programming
    Replies: 2
    Last Post: 05-04-2011, 08:32 AM
  2. SQL syntax
    By dssrun in forum Queries
    Replies: 4
    Last Post: 04-15-2011, 01:06 PM
  3. DLookup() syntax????
    By jgelpi16 in forum Programming
    Replies: 3
    Last Post: 03-30-2011, 09:14 AM
  4. Incomplete Syntax Clause (syntax error)
    By ajetrumpet in forum Programming
    Replies: 4
    Last Post: 09-11-2010, 10:47 AM
  5. dlookup() syntax
    By markjkubicki in forum Programming
    Replies: 4
    Last Post: 08-24-2010, 12:31 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