我的一个vba活动出现问题。
首先,事件在字段更改后触发,该字段属于一种表单,该表单显示一个表中的多个数据条目,该表单位于NavigationPane中。
我的数据库正在Access 2016 32位中进行编程,并且将大部分由工作人员在具有Access Runtime 2013的服务器上使用
现在,当我在PC上触发事件时,一切都按预期工作,但是在服务器运行时版本上,我看到一个错误,我将尝试将其翻译成英文,因为我在德国:“该程序的执行由于运行时错误而无法继续运行”-“此程序无法继续运行,将被关闭”。
我已经尝试过浏览鸭子,但是找不到我需要的东西,主要是因为关键字“运行时”在这种情况下具有两种不同的含义。
这是代码:
Private Sub isEnd_AfterUpdate()
Dim isEnd As Date
Dim rs As Recordset
Dim strFind As String
Dim test As Variant
'On Error Resume Next
Set rs = Recordset
With rs
If Not .EOF Then
isEnd = Me!isEnd
If Me!isStart > 0 Then
Me!isDur = (Me!isEnd - Me!isStart) * 24
End If
strFind = "IdMa = '" & Me!IdMa & "' and OrderRow = " & Me!OrderRow + 1
'test = MsgBox(strFind & " - " & rs.Name & " - '" & isEnd & "'", vbOKOnly, "test")
Me.Recordset.FindFirst (strFind)
Me!isStart = isEnd
Me.isEnd.SetFocus
End If
End With
End Sub
您可能会忽略我尝试用于调试的错误处理和MsgBox。
该数据库用于计划我们的流程,该字段保留已完成流程的结束时间,应将其输入到下一个流程的开始时间,以节省一点时间。
编辑1: 我应该提一下,我将错误定位到了下面:
Me.Recordset.Findfirst (strFind)
但无法弄清楚为什么会出现此问题,在同一表格的某些按钮中使用完全相同的行即可。
答案 0 :(得分:0)
尝试使用RecordsetClone,不要重复控件名称:
Private Sub isEnd_AfterUpdate()
Dim isEndDate As Date
Dim rs As DAO.Recordset
Dim strFind As String
Dim test As Variant
'On Error Resume Next
Set rs = Me.RecordsetClone
With rs
If Not .EOF Then
isEndDate = Me!isEnd
If Me!isStart > 0 Then
Me!isDur = (Me!isEnd - Me!isStart) * 24
End If
strFind = "IdMa = '" & Me!IdMa & "' and OrderRow = " & Me!OrderRow + 1
'test = MsgBox(strFind & " - " & .Name & " - '" & isEnd & "'", vbOKOnly, "test")
.FindFirst strFind
' and use the found record for something ..?
Me!isStart.Value = isEndDate
Me!isEnd.SetFocus
End If
.Close
End With
End Sub