我想移动的数据输入表单在微软访问现有的记录,如果一个匹配的记录已经存在



我有一个唯一的索引字段在我的表在微软访问。字段是Shift、Operator、Date_Field和Machine。我有一个数据输入表单,这些字段有组合框选项,除了自动填充今天日期的日期。我希望能够导航的形式,以匹配现有的移位/操作符/日期/机器组合的记录,如果它已经存在。我有一个DLookup函数,检查是否已经存在这样的记录,但现在我需要知道如何更改表单,使其在该记录上输入数据,而不是一个新的。

这是我目前所知道的。它被激活的AfterUdate中最后一个组合框标签的顺序之一。

Dim int_ID As Integer
With Me
'checks if duplicate record exists and stores it as int_ID variable
int_ID = Nz(DLookup("ID", "Tracking", "Shift= " & Val(.ShiftCbo) & " And Operator='" & .OpCbo.Column(1) & "' And Date_Field=#" & .DateBox & "# And Machine='" & .MachineCbo.Column(1) & "'"), 0)
End With
If int_ID <> 0 Then
'I need to know what to put here to take the form to the existing record.
End If

我尝试使用Cmd。GoToRecord,但这不起作用。

我最喜欢的(也是最简单的)方法之一是使用Me。Recordsource

一旦你的代码正确地定义了过滤条件,试着这样做:

Me.Recordsource= "select * from UnderlyingFormMainQuery where TextColumnName='" & varString & "' or NumericColumnName=" & intSomething
Me.Requery

相关内容

最新更新