Setting the Record Focus...

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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!
 
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
 

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