title: SQL Match on Username and Title
body: <p>I am trying to figure out which WHERE clause would work best for this problem. I need the query to show all the entries made by a specific user stored in the useUsername() function, unless that user has a titleID = 3 which is the Admin titleID. The titleIDs are stored in a different table called tblPlanner. I am trying to figure out if a WHERE clause or putting the theory in the useUserName() would work best. Here is the code</p>
  
  <pre><code>    SELECT tblClient.clientName, tblClient.clientFirmPartner, tblClient.clientRoot, tblClientPlan.offeringType, tblClientPlan.paidBy, tblClientPlan.regionalManager, tblClientPlan.plannerUser, tblClientPlan.clientID, tblClientPlan.offeringName, tblClient.clientIA, tblClient.clientAccount, tblClientPlan.lawyerName, tblClientPlan.allInfoDate
  FROM tblClient INNER JOIN tblClientPlan ON tblClient.clientID = tblClientPlan.clientID
  WHERE (((tblClientPlan.plannerUser)=useUserName()));
  </code></pre>
  
  <p>I am pretty new to this so any help would be great</p>
  
  <p>The useUsername() function is as follows</p>
  
  <pre><code>Option Compare Database
  Public strUserName As String
  
  Public Function useUsername()
      useUsername = strUserName
  
  
  End Function
  </code></pre>
  
  <p>It returns the value from the login form from the global variable via </p>
  
  <pre><code>strUserName = Me.txtUser.Value
  </code></pre>
  
  <p>The theory I have in my mind right now is as follows:</p>
  
  <pre><code>If (((DLookUp("tblPlanner.Title","tblPlanner","tblPlanner.userName"=useUsername()))=3)) 
  then show all values, else show the above query
  </code></pre>