How to go to last record?

  • Thread starter Thread starter Lee
  • Start date Start date
L

Lee

Hi guys
Can you help with the following?
I have a small form where users input a customer number,
hit the return key and the first record for the customer
is displayed on the MAIN form that is also open.
However, I'd really like the utility to jump to the most
recent (last) record for the customer rather than the
first record. Any ideas how I might achieve this? I get
in such a muddle opening recordsets, cloning and
bookmarking that I've given up on it and settled for the
FindRecord method instead! Here's the code:

If IsNull([txtJump]) Then
MsgBox "Enter a Customer No in the box.",
vbExclamation, "Oops!"

ElseIf DCount
("[CustNo]", "tbl_InspectionReports", "CustNo=" &
txtJump) < 1 Then
MsgBox "Sorry, customer not found.",
vbInformation, "Try again"
txtJump = ""
DoCmd.GoToControl "txtJump"
Exit Sub
Else
DoCmd.SelectObject
acForm, "frm_InspectionReports", False
DoCmd.GoToControl "cboCustNo"
DoCmd.FindRecord txtJump, acEntire, False,
acSearchAll, True, acCurrent, True
End If

Your help would be very much appreciated.

Many thanks,

Lee
 
Base your form on a query and include the date field in your customer record.
Set the sort for the date field descending and the most recent record for the
customer will always come up when the form opens.
 
Back
Top