If CurrentUser="" OR "" Then..

Sniper-BoOyA-

Registered User.
Local time
Yesterday, 16:47
Joined
Jun 15, 2010
Messages
204
Good Afternoon,

A few months ago, i added a function to a database to track changes that are being made using forms. Everything is working great, but i wanted to add some things to that module to see what the possibilities are.

Ive got a question about the following code.

Code:
If Not CurrentUser = "User1" Then
    If Not Screen.ActiveControl.OldValue = Empty Then
        strReason = InputBox("Wat is de reden voor deze wijziging? (Max 40 tekens)")
    End If

As you can see i am trying to grant user1 some form of immunity by not registering his changes. I was trying to add more users by using OR.

Code:
If Not CurrentUser = "User1" OR CurrentUser = "User2" Then
    If Not Screen.ActiveControl.OldValue = Empty Then
        strReason = InputBox("Wat is de reden voor deze wijziging? (Max 40 tekens)")
    End If

But it doesnt seem to have any effect at all. It still asks for a reason, and it will log the changes of User2 anyway.

What am i doing wrong here?
 
Code:
If Not CurrentUser = "User1" OR CurrentUser = "User2" Then
    If Not Screen.ActiveControl.OldValue = Empty Then
        strReason = InputBox("Wat is de reden voor deze wijziging? (Max 40 tekens)")
    End If
I could be wrong (and I'm sure someone will be quick to point it out if I am), but the above seems to be saying
'Do this if the current user is not User1 or if it is User 2'
Perhaps this would work
Code:
If Not CurrentUser = "User1" OR [B]Not [/B]CurrentUser = "User2" Then
    If Not Screen.ActiveControl.OldValue = Empty Then
        strReason = InputBox("Wat is de reden voor deze wijziging? (Max 40 tekens)")
    End If
In case it's of any use, I do something similar and once you get to more than a couple of exceptions, it becomes a little cumbersome to keep adding 'or' statements. These days, I store all exceptions in a table and use a lookup to see if the person should be exempt or not.
 
Alc is right, as a general rule try to avoid "NOT" contructions as they are 'complicated'
 

Users who are viewing this thread

Back
Top Bottom