I have a textbox call Staff_ID, I don't want my user to type the same Staff_ID . So I write the vba code like this
The problem when I try it I Have a message " Run time Error "3420" Object Invalid or no longer set.When I open the debug at ( rsc.findfirst stlinkcriteeria ) have a yellow color.
Please help me to solve this problem. Thank you
Code:
Private Sub Staff_ID_AfterUpdate() Dim SID As String Dim stLinkCriteria As String Dim rsc As DAO.Recordset Set rsc = Me.RecordsetClone SID = Staff_ID.Value stLinkCriteria = "[Staff_ID]=" & "'" & SID & "'" If DCount("Staff_ID", "[Employee]", stLinkCriteria) > 0 Then Me.Undo MsgBox "Staff_Id = " & SID & " Already Have..." _ & vbCr & vbCr & "Type another staff_ID.", vbInformation _ , "Data cannot Double" Me.New.SetFocus rsc.FindFirst stLinkCriteria Me.Bookmark = rsc.Bookmark End If Set rsc = Nothing End Sub
Please help me to solve this problem. Thank you
Comment