Am trying to find a record in a ynaset table "EM_EmpNumber" where EMEmpNo is equal to The text box value 'EnterEmpNo'
I don't understand why these don't work? Got DoCmd from help function Access 97 and the rec.FindFirst from book 'Beging Access 97 VBA Programmong by Smith and Sussman.
Any ideas? The .MoveNext works but is ineligant/Inafficient.
Private Sub EnterEmpNo_LostFocus()
'Look up EmpNo in Emp table - If found display Emp Name in txtEmpName
Dim strEmpNo As String
Stop
'This dosen't work!
'DoCmd.FindFirst EnterEmpNo
'If NoMatch Then
'MsgBox "no emp found"
'Else
'MsgBox "employee found!!!"
'End If
'This didn't work
'strEmpNo = EnterEmpNo
'EMrec.FindFirst "EM_EmpNumber = " & strEmpNo 'get error 3251 Operation not supported for this type of object
'This didn't work
'EMrec.FindFirst "EM_EmpNumber = " & strEmpNo 'get error 3251 Operation not supported for this type of object
'If EnterEmpNo = EMrec(0) Then
'txtEmpName = EMrec(2) & " " & EMrec(1)
'Else
'MsgBox "This is not a valid Employee Number"
'End If
'This works!!!
'EMrec.MoveFirst
'LoopEM:
'If EMrec.EOF Then
'txtEmpName = Null
'EnterEmpNo = Null
'MsgBox "This is not a valid Employee Number"
'ElseIf EnterEmpNo = EMrec(0) Then
'txtEmpName = EMrec(2) & " " & EMrec(1)
'Else
'EMrec.MoveNext
'GoTo LoopEM
'End If
End Sub
I don't understand why these don't work? Got DoCmd from help function Access 97 and the rec.FindFirst from book 'Beging Access 97 VBA Programmong by Smith and Sussman.
Any ideas? The .MoveNext works but is ineligant/Inafficient.
Private Sub EnterEmpNo_LostFocus()
'Look up EmpNo in Emp table - If found display Emp Name in txtEmpName
Dim strEmpNo As String
Stop
'This dosen't work!
'DoCmd.FindFirst EnterEmpNo
'If NoMatch Then
'MsgBox "no emp found"
'Else
'MsgBox "employee found!!!"
'End If
'This didn't work
'strEmpNo = EnterEmpNo
'EMrec.FindFirst "EM_EmpNumber = " & strEmpNo 'get error 3251 Operation not supported for this type of object
'This didn't work
'EMrec.FindFirst "EM_EmpNumber = " & strEmpNo 'get error 3251 Operation not supported for this type of object
'If EnterEmpNo = EMrec(0) Then
'txtEmpName = EMrec(2) & " " & EMrec(1)
'Else
'MsgBox "This is not a valid Employee Number"
'End If
'This works!!!
'EMrec.MoveFirst
'LoopEM:
'If EMrec.EOF Then
'txtEmpName = Null
'EnterEmpNo = Null
'MsgBox "This is not a valid Employee Number"
'ElseIf EnterEmpNo = EMrec(0) Then
'txtEmpName = EMrec(2) & " " & EMrec(1)
'Else
'EMrec.MoveNext
'GoTo LoopEM
'End If
End Sub