Scrolling to specific record in continuous subform

J

JB

I have this code on a main form in the Form_Load event. I am adapting
this from someone else's sample. I want the code to find and select
the first record in a continuous subform that is greater than or equal
to todays' date. Once it does that, I want the current selected record
to scroll up inside the subform to be the first record in view. I
think this is working properly to find the record but the record does
not scroll into view.

In one example, there are five records in the subform. The subform is
sized to show two records at a time. The fifth record has a date
greater than today's date. The lngCount variable gets set to 4. Is
there something else I need to do so the selected record scrolls into
view inside the subform?


Dim lngCount As Long
Dim rs As DAO.Recordset

Set rs = Me.frmReservationListDetail.Form.RecordsetClone
rs.MoveFirst
rs.FindFirst "[Loan_Date] >= Date()"
If rs.NoMatch Then
DoCmd.GoToRecord , , acLast
Else
lngCount = rs.AbsolutePosition
DoCmd.GoToRecord , , lngCount
End If
 
M

Mark A. Sam

Where did you assign a value to lngCount?

Else
lngCount = rs.AbsolutePosition
DoCmd.GoToRecord , , lngCount

The default value would be 0

Try this however for the Else clause:

Else
frmReservationListDetail.Form.RecordsetClone.Bookmark = rs.Bookmark

God Bless,

Mark A. Sam
 

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