Help in Dlookup from an input box

stephaniechongg

Registered User.
Local time
Tomorrow, 02:05
Joined
Feb 5, 2016
Messages
15
I need help for an access assignment i have from school.

I am trying to limit the managers and normal staff from accessing certain information in the database. I know that i can use a security level login but my submission is in a few days and i have yet to finish the other components.

So basically, the staff are all grouped in the Staff table and i wish to prompt users with an input box to key in their relevant StaffID to lookup to their StaffPosition whenever they click on a img that links to a sensitive form. The only people who should have access into this form should be the Store Manager or Supervisor. There are 3 positions; Store Manager, Supervisor and Full Timer.

Currently i have pieced together this string of coding which was a result of my lecturer and online research.


Private Sub imgPayslip_Click()
Dim EnterStaffID As Variant
EnterStaffID = InputBox("Enter your StaffID", "StaffID Required")
If DLookup("[StaffPosition]", "[Staff]", "[StaffID]='" & EnterStaffID) Then
If [StaffPosition] = "Store Manager" Then
DoCmd.OpenForm "formname", acNormal
DoCmd.Close acForm, "formname", acSaveYes
Else
MsgBox "You are not a manager/supervisor!"
End If
End If
End Sub

Please help me i still have to create a report and presentation slide by tuesday
 
ok,
Code:
Private Sub imgPayslip_Click()
    Dim EnterStaffID As String
    Dim strStaffPosition As String
    EnterStaffID = InputBox("Enter your StaffID", "StaffID Required")
    If EnterStaffID <> "" Then
        strStaffPosition = Nz(DLookup("[StaffPosition]", "[Staff]", "[StaffID]=" & Chr(34) & EnterStaffID & Chr(34)), "")
        If strStaffPosition = "Store Manager" Then
            DoCmd.OpenForm "formname", acNormal
            DoCmd.Close acForm, "formname", acSaveYes
        Else
            MsgBox "You are not a manager/supervisor!"
        End If
    End If
End Sub
 
Thank you so much arnelgp !!!!!!!!

I AM SO THANKFULLLLL
 
you're welcome ma'am.
 

Users who are viewing this thread

Back
Top Bottom