Private Sub cmdSearchEmployee_Click()
With datEmployee.Recordset
datEmployee.Recordset.Index = "idxid"
datEmployee.Recordset.Seek "=", txtIDNumber.Text
If .NoMatch = True Then
MsgBox ("No Record Found!")
Else
Me.txtLastName.Text = .Fields("lname")
Me.txtFirstName.Text = .Fields("fname")
Me.txtMiddleName.Text = .Fields("mi")
With datPosition.Recordset
Me.txtPosition.Text = .Fields("position")
End With
End If
End With
End Sub
答案 0 :(得分:0)
我看不到您已将“传递值”传递给名为datPosition
的DataControl。这可能是问题吗?例如你在哪里
With datPosition.Recordset
Me.txtPosition.Text = .Fields("position")
End With
......应该更像这样:
With datPosition.Recordset
.Index = "some_index??"
.Seek "=", "some_value??"
Me.txtPosition.Text = .Fields("position")
End With
另外,请考虑使用记录集'Filter
删除与您的条件不符的行,然后RecordCount
遍历符合条件的行。
进一步考虑通过在SQL代码中创建tblEmployee
和tblPosition
之间的连接来返回单个记录集,或者使用带有SHAPE语法的MsDataShape返回分层记录集。