Trying to get the RecieptNumber (autonumber) from the most recent record in the table 'Invoices' to store the value in the variable invoiceNum (integer).
Dim rstInvoices As Recordset
Set cdCurrentDatabase = CurrentDb
Set rstInvoices = cdCurrentDatabase.OpenRecordset("SELECT LAST ([RecieptNumber]) FROM Invoices;")
invoiceNum = rstInvoices("[RecieptNumber]").Value
Started VBA programming yesterday so appreciate any help that I will be able to understand.