Results 1 to 6 of 6
  1. #1
    New Lounger
    Join Date
    Feb 2001
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Set permissions on fields in a form?

    We need a means to track software issues, so I created an online .doc form in Word 2000. The boss just came back and asked if it's possible to restrict access to certain fields based on the current user who's got the form open. Is there a way to do this? Am I even doing this in the best Office application for the task at hand?

  2. #2
    BAM
    Guest

    Re: Set permissions on fields in a form?

    Hi Bill,

    Woody would probably use Access for this task. <grin>

    Personally I wouldn't do this in Word. Access can do exactly what you/your boss wants and with less effort.
    ~~~~~~~~~~
    Cheers!

  3. #3
    Platinum Lounger
    Join Date
    Dec 2000
    Location
    Queanbeyan, New South Wales, Australia
    Posts
    3,730
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Set permissions on fields in a form?

    Bill,

    I think it's possible. BAM's point is valid- it may be that you're better with another solution- even a UserForm- but it can be done.

    However, the viability of what you want may be subject to whether you can interrogate the userID, and to find the access required for that user.

    You can protect a field in code by:
    ActiveDocument.FormFields("Text1").Enabled = False
    Subway Belconnen- home of the Signboard to make you smile. Get (almost) daily updates- follow SubwayBelconnen on Twitter.

  4. #4
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,852
    Thanks
    4
    Thanked 259 Times in 239 Posts

    Re: Set permissions on fields in a form?

    I also agree that this is job for Access but it can be done in Word if you want the headache of maintaining access priviledges

    Here is some sample code which does the hard parts. Note this code comes from an Access module but should work equally well in Word.
    <pre>Option Explicit
    Public bHaveRights As Boolean
    Public sUserName As String
    Private Declare Function apiGetUserName Lib "advapi32.dll" Alias _
    "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
    '================================================= ==============
    Public Function LockedArea(sUserName As String)
    'Function determines whether the user is allowed unlimited access
    Select Case sUserName
    Case "logon1", "logon2", "logon3"
    bHaveRights = True
    Case Else
    bHaveRights = False
    End Select
    End Function
    '================================================= ==============
    Function fLogName() As String
    ' Returns the network login name
    Dim lngLen As Long, lngX As Long
    Dim sUserName As String
    sUserName = String$(254, 0)
    lngLen = 255
    lngX = apiGetUserName(sUserName, lngLen)
    If lngX <> 0 Then
    fLogName = Left$(sUserName, lngLen - 1)
    Else
    fLogName = ""
    End If
    End Function</pre>

    Andrew Lockton, Chrysalis Design, Melbourne Australia

  5. #5
    Platinum Lounger
    Join Date
    Dec 2000
    Location
    Queanbeyan, New South Wales, Australia
    Posts
    3,730
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Set permissions on fields in a form?

    Andrew,

    I imagine this only works in a limited environment.

    On our WinNT system, Office 2000 SR-1, we can get the logged on user by 'environ("Username")'.

    I believe it's a WinNT thing- it used to work in Word97 as well- but it may also be particular to the wat WinNT is set up.
    Subway Belconnen- home of the Signboard to make you smile. Get (almost) daily updates- follow SubwayBelconnen on Twitter.

  6. #6
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,852
    Thanks
    4
    Thanked 259 Times in 239 Posts

    Re: Set permissions on fields in a form?

    Geoff

    I think you will find it works on more systems than the environ("Username") does. I could not get that one to work on Win95 systems and it may therefore not work on Win98 systems either. The method I posted is ugly but does do the trick in both WinNT and Win95.
    Andrew Lockton, Chrysalis Design, Melbourne Australia

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •