title: MS Access Dmax: I have 13 rows of different Pets and need to find Last Visit for each?
body: <p>The problem: Create a <code>LastVisitDate</code> field/column using the <code>DMax</code> function based on <code>Pet</code>.</p>
  
  <p>The only tables I am allowed to use are <code>tbl_Customer</code> and <code>tbl_Pets</code>. I am suppose to add a field and use the Expression builder using <code>Dmax</code> accessing/referencing <code>tbl_Visits</code> that has <code>PetID</code> (text field). I have 13 distinct records to find their last visit date for each in the query. This is what I have:</p>
  
  <pre><code>LastVisit: DMax("VisitDate","tbl_Visits","[PetID]= " &amp; 'PetID')
  </code></pre>
  
  <p>But, it returns a single date( which is the latest date in the Visits table) for all the records, which is incorrect. </p>
  
  <p>I also tried this, but it returns nothing:</p>
  
  <pre><code>LastVisit: DMax("VisitDate","tbl_Visits","[PetID]= '*'")
  </code></pre>
  
  <p>I know the error has to do with how I have set up my "Criteria." Any Suggestions? Thanks in advance.</p>
  
  <p>(I have an alternate way of adding Visits table, VisitDate and then do Totals and Group By "Max" which gets me the result, but I am not suppose to be adding <code>tbl_visits</code> to my query.)</p>