Results 1 to 5 of 5
  1. #1
    5 Star Lounger
    Join Date
    May 2003
    Location
    Sheffield, Yorkshire
    Posts
    951
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Protect Field (2003)

    I've been asked if I cannot protect the input into a field on a form. I think I know what code to use, but I'm not sure which property it should go in, BeforeUpdate, AfterUpdate or what?

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Protect Field (2003)

    You don't need code for that. If you want to prevent the user from entering and editing the field,simply set the Locked property of the text box bound to the field to Yes. The user will still be able to click in the text box and copy the contents for use elsewhere. If you also want to prevent that, set the Enabled property of the text box to No. The user won't be able to click in the text box any more. (Note: if you set Enabled to No and Locked to Yes, the text box will be greyed out)

  3. #3
    5 Star Lounger
    Join Date
    May 2003
    Location
    Sheffield, Yorkshire
    Posts
    951
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Protect Field (2003)

    Sorry, I didn't make myself clear. One user needs to be able to enter data into the form.

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Protect Field (2003)

    You can use code in the On Load event of the form to set the Locked and Enabled properties of the text box according to who opens the form.
    If you have applied user-level security, you can use CurrentUser for this, otherwise, use the GetNetUser function from <post#=446010>post 446010</post#> to get the network login name.

    Example:

    Private Sub Form_Load()
    If CurrentUser = "robm" Then
    Me.txtSomething.Locked = False
    Me.txtSomething.Enabled = True
    Else
    Me.txtSomething.Locked = True
    Me.txtSomething.Enabled = False
    End If
    End Sub

    If you haven't applied user-level security, replace CurrentUser with GetNetUser. And substitute the correct user name of the person who should be able to edit the field.

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Protect Field (2003)

    Umm, wait, do you want to apply this to the form as a whole, or just to a single text box?

Posting Permissions

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