Jump to Specific Record

  • Thread starter Thread starter John C.
  • Start date Start date
J

John C.

I have a query, that is based on a table that contains a
plethera of information on individuals. The table is
indexed on the last name.

The query sorts the information by last name, ascending.
No criteria is stipulated.

The form used to display this information has command
buttons for each letter of the alpa.

I want each button to "jump" or "goto" the first record
that the last name starts with the corresponding letter of
the command button selected.

I could not find a "jump" or "goto" command...
 
No, but you can do this using code similar to the following on each command
button. This example is for the button "A":

Private Sub cmdButtonA_Click()
With Me.RecordsetClone
.MoveFirst
.FindFirst "[LastNameFieldName] Like 'A*'"
If .NoMatch = True Then
MsgBox "There is no entry whose last name begins with 'A'."
Else
Me.Recordset.Bookmark = .Bookmark
End If
End With
End Sub
 
Thankyou Ken. That had several commands that I have not
used before, I will explore more with these.

I shortened the code to:

With Me.RecordsetClone
.MoveFirst
.FindFirst "[LastName] Like 'A*'"
If .NoMatch = False Then
Me.Recordset.Bookmark = .Bookmark
End If
End With
 
When using bookmarks in this way or even the
RecordsetClone, will/is there anything that will "buildup"
in the memory and need released?

Figuring the app will stay open for a long period of time,
and lots of button pushes.
 
Back
Top