简体   繁体   English

在MS Access中设置焦点

[英]Setting focus in MS Access

I am creating a recordset from a Qdefs and then displaying the records in a form. 我正在从Qdefs创建一个记录集,然后以表格形式显示记录。

When I filter the values, focus is going to the first record. 当我过滤值时,焦点将移到第一条记录。 But, I want the focus to point to the same record that was in focus before filtering. 但是,我希望焦点指向过滤之前焦点所在的同一记录。

This is how am creating a recordset from an existing querydefs before and after filtering 这是在过滤之前和之后从现有querydefs创建记录集的方式

db.QueryDefs("Query_vinod").Sql = filter
Set rs_Filter_Rowsource = db.OpenRecordset("Abfr_SSCI_Check_Findings_List")

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. 设置一个RecordsetClone,然后使用FindFirst方法查找您的活动记录。 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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM