IIf on textbox (1 Viewer)

AndyCompanyZ

Registered User.
Local time
Today, 02:03
Joined
Mar 24, 2011
Messages
223
I am trying to write a piece of code that will show me an ID number from a table if certain criteria is met. The code I have so far is:
Code:
= IIf(DLookUp( [tblSubTeam]![SubTeamHeadDelID] ,[tblSubTeam], = [DelegateID])), [tblSubTeam]![SubTeamParentID] , [tblSubTeam]![SubTeamHeadDelID]

this is on the control source of the textbox. But it is gving me an invaild syntax error and I'm not sure where. What the code should do islookup the tblSubTea, and look for the SubTeamHeadDelID and if it is the same as the DelegateId then it shows the SubTeamParentID from the tblSubTeam and if not then show the SubTeamHeadDelID. I'm not sure if this is the correct use of the IIf statement as it's the first time I've tried using it hence the syntax error.
 

AndyCompanyZ

Registered User.
Local time
Today, 02:03
Joined
Mar 24, 2011
Messages
223
I've changed it slightly but still says the same syntax error

Code:
= IIf((DLookUp( "[SubTeamHeadDelID]" ,"[tblSubTeam] =" &  "[DelegateID"]), [tblSubTeam]![SubTeamParentID] , [tblSubTeam]![SubTeamHeadDelID])
 

AndyCompanyZ

Registered User.
Local time
Today, 02:03
Joined
Mar 24, 2011
Messages
223
I have changed it again because it said I needed a closing parentheses to:
Code:
= IIf((DLookUp( "[SubTeamHeadDelID]" ,"[tblSubTeam] =" &  [DelegateID]), [tblSubTeam]![SubTeamParentID] , [tblSubTeam]![SubTeamHeadDelID]))

But this now says wrong number of arguments.
 

AndyCompanyZ

Registered User.
Local time
Today, 02:03
Joined
Mar 24, 2011
Messages
223
Realised I had a mistake that it wasn't referencing the field on the form so now says:

= IIf((DLookUp( "[SubTeamHeadDelID]" ,"[tblSubTeam]", "[Me]![SubTeamHeadDelID] =" & [DelegateID]), [tblSubTeam]![SubTeamParentID] , [tblSubTeam]![SubTeamHeadDelID]))

But still says wrong number of arguments.4
 

Users who are viewing this thread

Top Bottom