0

I'm using Access as a front end to SQL Server. We have a split form where the users select a record, insert some new information with the form, then continue on to the next record. My manager would like to see how long it takes a user to modify a record. So I would like a timer to start when someone clicks on a record then it to stop when they click on the next record or when they select complete in the form. I would like this imformation exported to an excel sheet. It might be easier to get the average time for each user since most users are modifiying over 100 records per day. Is there anyway this is possible?

4

2 回答 2

1

简单的解决方案:您可以在表单的On Dirty事件中编写一个函数,并将一条记录添加到具有当前记录的 ID、用户名和当前时间(开始时间)的表中。在表单的On AfterUpdate中,使用函数更新同一条记录并将当前时间添加为(结束时间)。当用户开始编辑或添加记录时,时间会记录在此表中。当他/她更新记录时,时间被添加为结束时间。

现在您有一个包含 ID、用户名、开始时间、结束时间的表。通过查询,您可以计算每条记录从编辑开始、结束到更新所花费的时间。您可以随时将此表导出到 Excel 工作表。

复杂的方法:

我也有类似的情况。如果用户在指定时间内空闲(针对网络流量问题),我被要求关闭数据库

我在表单的计时器事件中使用了波纹管功能。它每 5 秒读取一次活动表单的名称并将其保存在静态变量中。此函数每 5 秒将 Screen.activeform.name 与此静态变量进行比较。如果活动表单的名称与此静态变量不同,则表明用户处于活动状态(正在做某事),因此它会重置计时器静态变量。否则表示用户空闲并添加定时器。

当计时器达到应用程序选项中设置的指定量(比如说 5 分钟)时,这意味着用户已经空闲了 5 分钟,我只需运行 Application.Quit 并关闭数据库。

我现在很忙,没有时间处理它。您可以修改此函数以检查当前记录甚至当前控件(而不是当前表单),并且在重置静态计时器变量之前,将计时器变量、记录的用户名和 ID 导出到表中并使用查询计算花费的时间并将其导出到excel。

希望能帮助到你。

如果我这个周末有空,我会尝试做一个简单的数据库来展示它是如何工作的

我的计时器:

' IDLEMINUTES determines how much idle time to wait for before
' running the IdleTimeDetected subroutine.

IdleMinutes = fGetOption("Machine", "AutoLogOff", False)
If IdleMinutes = 0 Then Exit Sub

Static PrevControlName As String
Static PrevFormName As String
Static ExpiredTime

Dim ActiveFormName As String
Dim ActiveControlName As String
Dim ExpiredMinutes

On Error Resume Next



    ' Get the active form and control name.

    ActiveFormName = Screen.ActiveForm.Name
    If Err Then
        ActiveFormName = "No Active Form"
        Err = 0
    End If

    ActiveControlName = Screen.ActiveControl.Name
    If Err Then
        ActiveControlName = "No Active Control"
        Err = 0
    End If

    ' Record the current active names and reset ExpiredTime if:
    '    1. They have not been recorded yet (code is running
    '       for the first time).
    '    2. The previous names are different than the current ones
    '       (the user has done something different during the timer
    '        interval).
    If (PrevControlName = "") Or (PrevFormName = "") _
        Or (ActiveFormName <> PrevFormName) _
        Or (ActiveControlName <> PrevControlName) Then
        PrevControlName = ActiveControlName
        PrevFormName = ActiveFormName
        ExpiredTime = 0
    Else
        ' ...otherwise the user was idle during the time interval, so
        ' increment the total expired time.
        ExpiredTime = ExpiredTime + Me.TimerInterval
    End If

    ' Does the total expired time exceed the IDLEMINUTES?
    ExpiredMinutes = (ExpiredTime / 1000) / 60
    'Debug.Print ExpiredMinutes
    If ExpiredMinutes >= IdleMinutes Then
        ' ...if so, then reset the expired time to zero...
        ExpiredTime = 0
        ' ...and call the IdleTimeDetected subroutine.
        IdleTimeDetected ActiveFormName
    End If







    Sub IdleTimeDetected(ActiveFormName As String)

        DoCmd.Close acForm, ActiveFormName

        CloseAllForms
        Application.Echo True
        Application.Quit

    End Sub    
于 2013-03-19T01:05:17.103 回答
0

这是一个简单的示例数据库来帮助您。

样本数据库

这个数据库是用Office 2013写的,希望你能打开。打开 frm 表单并开始编辑记录或开始插入新记录。编辑/插入记录的开始和结束将记录在结果表中。您可以在一天结束时将此表导出到 Excel 文件。

请注意,此数据库需要一些修改。例如你必须添加一些代码来识别当前的用户名我认为你可以管理这个部分

于 2013-03-21T00:29:12.710 回答