Setting focus in MS Access

前端 未结 1 1281
忘掉有多难
忘掉有多难 2021-01-27 06:17

I am creating a recordset from a Qdefs and then displaying the records in a form.

When I filter the values, focus is going to the first record. But, I want the focus to

1条回答
  •  广开言路
    2021-01-27 06:47

    I think you can do this by using a bookmark. Set up a RecordsetClone and then find your active record by using the FindFirst method. I have some sample code that will need to be modified a little to fit your exact variables:

    Dim Rs As Recordset
    Dim Test As Integer
    Dim varBookmark As Variant
    
    DoCmd.OpenForm "Contracts"
    
    
    Set Rs = Forms!Contracts.RecordsetClone
    
        Rs.FindFirst ("[ID] = '" & Me![ID] & "'")
    
    varBookmark = Rs.Bookmark
    Forms!Contracts.Form.Bookmark = varBookmark
    
    If Rs.NoMatch Then
      MsgBox "That does not exist in this database."
    Else
    End If
    

    0 讨论(0)
提交回复
热议问题