How to go to last record?

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
 
P

PC Datasheet

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top