Setting the Record Focus...

H

Heidelberg

When I open my forms the wrong record is highlighted. How do I set the focus
on to another particular record, so the form opens focused on that new
record?

Thanks!
 
K

Ken Sheridan

In the form's Load event procedure you'll need to first find the record in
the form's recordset using its Clone property then synchronize the bookmarks
of the form and the close of its recordset, e.g. the following code finds a
record by its numeric primary key MyID

Dim rst As Object
Dim strCriteria As String

strCriteria = "MyID = " & <get MyID value from somewhere>

Set rst = Me.Recordset.Clone
rst.FindFirst strCriteria

If Not rst.EOF Then
Me.Bookmark = rst.Bookmark
End If

Somehow you have to determine the value of MyID when the form opens. This
might be a literal value, a reference to a control on another form or a value
passed into the form as its OpenArgs property via the OpenForm method.

Ken Sheridan
Stafford, England
 
Top