Determine if I'm at the last record in recordset

  • Thread starter Thread starter Larry Hodges
  • Start date Start date
L

Larry Hodges

Hi all,

Running A2002

I have a main form with subform. From that subform, I launch a popup form
for data entry. When I close the popup form, I want to do one of two
things.

1. If the popup was launched from the middle of the recordset (anywhere BUT
the last record in the recordset), simply set the focus back on the field
txtUnitNumber.

2. If the user was already at the last record, then move to a new record in
the recordset.

This code launches from the popup form on it's Close event and points to the
main form and it's subform:

Forms!frmCustomerLumberTally!frmCustomerLumberTallyUnit.Form.Recordset.AddNew
Forms!frmCustomerLumberTally!frmCustomerLumberTallyUnit.Form![txtUnitNumber].SetFocus

It works fine. But I need to use an If/Else to accomplish one of the 2
above tasks. So, can I determine if I am at the last record in the
recordset?

Thanks in advance,
-Larry
Maximize Software, Inc.
 
Here's one way:

With Me.RecordsetClone
.MoveLast
If Me.Recordset.AbsolutePosition + 1 = .RecordCount Then
MsgBox "at last record"
Else
MsgBox "not at last record"
End If
End With
 

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

Back
Top