Log in

View Full Version : Creating button to cross-reference access level


JoKate
Nov 8, 2019, 04:26 PM
I'm creating a database to log incidents and then build the incident report from the log. On my frmFinalIncRpt I have three fields which need to be approved by generally three different people at three different times.

I'm trying to code buttons to compare the name in two tables "tblUsers" and "tblIncidentReportLog" and only let you approve if the person logged in matches the person named in the final report. The action the button should take would be entering the text of that person's name in the signature field. Or denying you if you're not the right person.

I've tried Frankenstein-ing it just to see if I could get the front half right and I can't. I don't know if a DoCmd will work but the "frm5DyInc" is just a place holder. I'm pretty lost so really any guidance here would help. I've restricted access on most of the forms using the [AccessLevel] but I'd like to use [Password] here as I have 8 users that need unique approval access.

Private Sub btnFinalApv_Click()
If DLookup("[Password]", "tblUsers", "[ID] = " & Forms!frmLogin!cboUser) = DLookup("[ApproverName]", "tblIncidentReportLog") Then
DoCmd.OpenForm "frm5DyInc"
Else
MsgBox "You do not have access", vbOKOnly
End If
End Sub