Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with selecting a record

Status
Not open for further replies.

planetdrouin

Technical User
Dec 29, 2001
36
US
I have a form that is supposed to delete the user information as far as security is concerned and also delete the employee's contact information. On my form I have one input field that is unbound and a button to delete information. The error I am getting is "The Microsoft Jet database engine does not recognize 'Lawrence' as a fieldname or expression." My code is as follows:

Private Sub Delete_Click()
On Error GoTo Err_Delete_Click
Dim wspWorkspace As Workspace, usr As User, db As DAO.Database, rs As DAO.Recordset
Set wspWorkspace = DBEngine(0)
Set usr = wspWorkspace.Users(Me.Inputfield.Value)
Set db = CurrentDb
Set rs = db.OpenRecordset("tblemployees")
wspWorkspace.Users.Delete Me.Inputfield
rs.FindFirst "employeename like " & Me.Inputfield.Value
rs.Delete
Exit_Delete_Click:
Exit Sub
Err_Delete_Click:
If Err = 3265 Then
Me.Inputfield.SetFocus
MsgBox "That employee name does not exist.", vbExclamation, "Error"
Else
MsgBox Err.Description
End If
Resume Exit_Ok_Click
End Sub

The code works as far as deleting the user for security purposes, but it is the openrecordset part that is not working. The table tblemployees is linked and the primary key is empID and the code works if I enter the empID number. However, I want to input EmployeeName which is a name.Can anyone help me fix this problem?

Thanks

Lawrence
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top