title: Access (VBA) accessing the last record in a record set
body: <p>Trying to get the RecieptNumber (autonumber) from the most recent record in the table 'Invoices' to store the value in the variable invoiceNum (integer).</p>
  
  <pre><code>Dim rstInvoices As Recordset
  
  Set cdCurrentDatabase = CurrentDb
  Set rstInvoices = cdCurrentDatabase.OpenRecordset("SELECT LAST ([RecieptNumber]) FROM Invoices;")
  
  invoiceNum = rstInvoices("[RecieptNumber]").Value
  </code></pre>
  
  <p>Started VBA programming yesterday so appreciate any help that I will be able to understand.</p>