Compare Username on Report to Table

twac1382

New member
Local time
Today, 09:44
Joined
Mar 20, 2015
Messages
9
Hi,

I'm working on creating an events log. In my table I've got a field that pulls the individual's username (that they use to log into the computer) and logs it against their log entry.

As part of my query (for my daily events log report) I'm pulling up said username.

I'd like to give access to the specific user to edit his (and only his) entries from the report, but I'm getting a type mismatch with the below code:
Code:
    If me.UsernameID = "KraussLJ" Or Environ$("Username") Then
        DoCmd.OpenForm "frmShiftLog"
        DoCmd.FindRecord Me.ID, acStart, , acSearchAll, , acAll
    Else
        MsgBox ("You are not authorized to edit this entry")
    End If
(before you ask, "KraussLJ" is our ops manager who insists on having final editorial control over the shift log before sending it higher up the chain)

I can get the msgbox to run if I block out the
Code:
Environ$("Username")
, but beyond that I'm a little stuck. Should this be a dlookup function or am I overanalyzing this way too much?

Thanks for all of the help, this site has been a life saver on a lot of occassions! :D
 
Environ$ is a function the returns an answer, and you didnt ask it anyting.

i think you want:
If me.UsernameID = "KraussLJ" Or Environ$("Username")= "KraussLJ"
 
[SOLVED] Compare Username on Report to Table

That was pretty much it. I re-worded my code to:
Code:
If me.usernameID = Environ$("Username") or Environ$("Username") = "krausslj" then

I appreciate your help...guess I just needed to step back a moment and get a second set of eyes to look at the code.
 

Users who are viewing this thread

Back
Top Bottom