Re: Locked property

From: Allen Browne (AllenBrowne_at_SeeSig.Invalid)
Date: 07/20/04


Date: Tue, 20 Jul 2004 11:42:44 +0800

UserID is a Text type field?
CurrentUser() is a function, so try adding the brackets.

This example sets a flag to lock the text boxes if the UserID in the form is
not the same as CurrentUser(). It also locks the fields if there is not
UserID (e.g. at a new record).

Private Sub Form_Current()
    Dim bLock As Boolean
    bLock = Not Nz(Me!UserID = CurrentUser(), False)
    Me!Response.Locked = bLock
    Me!Sign_Off.Locked = bLock
End Sub

-- 
Allen Browne - Microsoft MVP.  Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"shaggles" <anonymous@discussions.microsoft.com> wrote in message
news:00c601c46dc9$409ad700$a501280a@phx.gbl...
> I am trying to set the Locked property of a comment field
> based on the user id.  I got the following code from vb
> help in access but I get an error message saying the
> object doesn't support this property or method.  The field
> I'm trying to lock are on a subform.  Does that make a
> difference?  I put the code in the On Curent event of the
> subform.
> Private Sub Form_Current()
> If Me!UserID = CurrentUser Then
> Me!Response.Locked = False
> Me!Sign_Off.Locked = False
> Else
> Me!Response.Locked = True
> Me!Sign_Off.Locked = True
> End If
> End Sub


Relevant Pages

  • Re: Locked property
    ... > I keep getting the same error message no matter what I ... UserID is a text field. ... >>> I'm trying to lock are on a subform. ... >>> Private Sub Form_Current ...
    (microsoft.public.access.modulesdaovba)
  • Re: Switch Function
    ... CurrentUser() values, and the second field storing the 'id' that the user ... Drag the field UserId from AccessRights into the grid, add the criteria, ... UserID, one on CanSee, one on whoWriteIt. ... WHERE userID = SWITCH(... ...
    (microsoft.public.access.queries)
  • Re: Passing login ID to query.
    ... and then a built in function (the CurrentUser()) delivered ... database dows to limit ... You can also log record modification timestamps ... >data once you learn to grab the userid. ...
    (microsoft.public.access.security)
  • Re: LDAP
    ... I'm concerned, rightfully or wrongfully, that if a multifunction device is comprised, the compriser, depending on their skill level, may be able gain access to other parts of the network as mentioned above. ... If you really want to lock down what can be seen, consider pointing the devices to an ADAM you populate with the needed data instead. ... With respect to security, how should this userid be configured, e.g. minimal ...
    (microsoft.public.security)
  • Re: Switch Function
    ... CurrentUser() values, and the second field storing the 'id' that the user ... Drag the field UserId from AccessRights into the grid, add the criteria, ... WHERE userID = SWITCH(... ...
    (microsoft.public.access.queries)