Lock field if not previously completed by user (1 Viewer)

tucker61

Registered User.
Local time
Today, 12:02
Joined
Jan 13, 2008
Messages
321
I have a subform which contains a field called Tbdesc, which is locked if the field is not null

Code below.
I want to add another criteria to this so that the field is unlocked if the user entered the original data.

Code:
If Nz(tbDesc, "") = "" Then
        tbDesc.Locked = False
        tbDesc.SetFocus
    Else
        tbDesc.Locked = True
        End If
    End If

So i am thinking it will be

Code:
If Nz(tbDesc, "") = "" Then
        tbDesc.Locked = False
        tbDesc.SetFocus
    Else
[INDENT][INDENT]If tbusername = '" & Environ("UserName") & "' then
        tbDesc.Locked = false
else
        tbDesc.Locked = True
End If[/INDENT][/INDENT]
End If

Would this work ?

My form with this data contains the fields below.

tbJobID, tbusername, tbCommentdate, tbdesc.
 

Mark_

Longboard on the internet
Local time
Today, 12:02
Joined
Sep 12, 2017
Messages
2,111
Have you tried it? Did it work? Did you get an error?

I am guessing your if should be
Code:
If tbusername = Environ("UserName") then
instead of
Code:
If tbusername =[COLOR="Red"] '" & [/COLOR]Environ("UserName")[COLOR="red"] & "' [/COLOR]then
as Environ returns a string.
 
Last edited:

tucker61

Registered User.
Local time
Today, 12:02
Joined
Jan 13, 2008
Messages
321
Thanks, your guess was correct...
 

Mark_

Longboard on the internet
Local time
Today, 12:02
Joined
Sep 12, 2017
Messages
2,111
NOTE: Only reason I guessed is I don't know what type of variable you save tbusername as. I've a feeling there's at least one person who decided that a DATE/TIME would be a good way to go. :eek:
 

Users who are viewing this thread

Top Bottom