I didn't understand how to do it that way. I tried this but it gives me a few errors like undefined funciton Employees.AccessOption.Column in expression...Too few parameters. Expected 1. .... and object variable or with block variable not set...Can someone let me know whats wrong please.....What i'm doing is this. On the switchboard the user click his name and hits the view my info button and it takes him to a sign in form (UserAccess) that varifies his username and password. When he is allowed access the EmployeeInfo form opens. If he is an employee then he can only view his info so i set the recordsource to view just him. If he is an administrator he is allow to view everybody. In my Employees table i have a field named AccessOption which is a combobox which is a value list and it lets you either choose employee or administrator. Can someone please give me a hand. I appreciate it and thanks in advance.
Private Sub Form_Open(Cancel As Integer)
On Error GoTo MyErrorControl
'If the user that signed in has employee access do this
If DLookup("[AccessOption]", "Employees", "Employees.AccessOption.Column(1)") Then
Dim UserDB As Database, UserRS As Recordset
Set UserDB = CurrentDb
Set UserRS = UserDB.OpenRecordset("SELECT * FROM Employees WHERE Employees.[First Name] = Forms!UserAccess.UserName")
Me.ButtonFirstRecord.Enabled = False
Me.ButtonPreviousRecord.Enabled = False
Me.ButtonNextRecord.Enabled = False
Me.ButtonLastRecord.Enabled = False
'If the user that signed in has administrator access do this
ElseIf DLookup("[AccessOption]", "Employees", "Employees.AccessOption.Column(2)") Then
Dim DB As Database, RS As Recordset
Set DB = CurrentDb
Set RS = DB.OpenRecordset("SELECT * FROM Employees")
RecordCount.Value = 0
RS.MoveLast
RS.MoveFirst
RecordCount.Value = RS.RecordCount
RecordNumber.Value = 1
ButtonFirstRecord.Enabled = False
ButtonPreviousRecord.Enabled = False
If RS.RecordCount < 2 Then
ButtonLastRecord = False
ButtonNextRecord = False
End If
End If
RS.Close
Set RS = Nothing
Set DB = Nothing
Exit Sub
MyErrorControl:
Select Case Err.Number
Case 0
Resume Next
Case Else
MsgBox "Error " & Err.Number & ": " & Err.Description, vbCritical, "Form_BeforeUpdate ERROR"
Resume Next
End Select
End Sub