仅访问 MS Access 中的过滤值 table

Access only filtered values in a MS Access table

是否可以从应用过滤器后显示的 Access table 中的行获取值?

请求示例:

我有一个 table,员工可以在其中填写项目任务、项目时间等。 它在表格上制作为 table。这些列在首字母、项目编号等方面的选择有限。人们喜欢在访问 table 和查询时通过内置的筛选功能对 table 进行排序。我进行了过滤,因此示例中仅显示项目 LT1075。

我怎样才能将这 4 行作为记录集或类似的东西?我需要获取所有小时字段中的值。我还需要只复制 VBA 中的那 4 行并对它做一些事情(人们想要的功能)。但是当我使用 DAO 时,我得到 "Unfiltered" table.

中的所有行

如何只显示行?

在excel中有一个简单的功能,有cells_visible的东西但是我找不到访问权限。

最好的问候,埃米尔。

编辑、试用:

Public Sub Test1_Click()

Dim rs As DAO.Recordset
Set rs = Me.RecordsetClone
While Not rs.EOF
    ' Do calculation stuff on record.
    rs.MoveNext
Wend

End Sub

放在上图中的"Test 1"按钮上

我收到错误:"Runtime error 7951 - You entered an expression that has an invalid reference to the RecordsetClone property"

我有一个线索,因为 Me.* 函数它不起作用?由于 table 是某种子形式。但我在导航面板中只看到一种形式。 (隐藏的也显示)。

您可以使用以下形式的 RecordsetClone:

Dim rs As DAO.Recordset
Set rs = Me.RecordsetClone
While Not rs.EOF
    ' Do calculation stuff on record.
    rs.MoveNext
Wend

并且您可以将记录添加到记录集中:

Public Sub CopyRecords()

    Dim rstSource   As DAO.Recordset
    Dim rstInsert   As DAO.Recordset
    Dim fld         As DAO.Field
    Dim strSQL      As String
    Dim lngLoop     As Long
    Dim lngCount    As Long

    strSQL = "SELECT TOP 1 * FROM tblStatus"

    Set rstInsert = CurrentDb.OpenRecordset(strSQL)
    ' rstSource can be any recordset, here the RecordsetClone of the form.
    Set rstSource = Me.RecordsetClone

    With rstSource
       While Not .EOF
           With rstInsert
               .AddNew
               For Each fld In rstSource.Fields
                   With fld
                       If .Attributes And dbAutoIncrField Then
                           ' Skip Autonumber or GUID field.
                       ElseIf .Name = "Total" Then
                           ' Special cases.
                           ' Insert default job code.
                           rstInsert.Fields(.Name).Value = 0
                       ElseIf .Name = "PROCESSED_IND" Then
                           rstInsert.Fields(.Name).Value = vbNullString
                       Else
                           ' Copy field content.
                           rstInsert.Fields(.Name).Value = .Value
                       End If
                   End With
               Next
               .Update
           End With
           .MoveNext
        Next
        rstInsert.Close
        .Close
    End With

    Set rstInsert = Nothing
    Set rstSource = Nothing

End Sub