1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Solved: Allow edits certain fields only

Discussion in 'Business Applications' started by tomlock2, Dec 20, 2011.

Thread Status:
Not open for further replies.
Advertisement
  1. tomlock2

    tomlock2 Thread Starter

    Joined:
    Nov 20, 2011
    Messages:
    49
    I have a form whose ALLOWEDITS is set to NO.
    I want to be able to allow edits only on certain data presented in the form. In the On Got Focus event for a field whcih I want to be able to allow edits on I inserted the VBA code Allowedits=True. That allows me to edit data in that field. Then in the On Lost Focus event for that field I inserted the VBA code Allowedits=False.

    So when I move to the next field on the form I would expect not to be able to edit it. However I can. The On Lost Focus event did not set the Allowedits=False command somehow.

    Any thoughts on why?
     
  2. Rockn

    Rockn

    Joined:
    Jul 29, 2001
    Messages:
    21,334
    Either you want to allow edits on a field or you don't. It really doesn't make sense to allow the edit and then to not allow it for the same field.
     
  3. tomlock2

    tomlock2 Thread Starter

    Joined:
    Nov 20, 2011
    Messages:
    49
    That's not what I'm doing. I set the allowedits=true on a field when that field gets the focus and when it loses focus (because I move the focus to a different field on the form) I want to reset the allowedits of the form to false. So I do that in the On Lost Focus event. However for some reason that Allowedits=false doesn't work.
     
  4. OBP

    OBP

    Joined:
    Mar 8, 2005
    Messages:
    19,895
    Why not use the Locked or Enabled functions instead.
    To overcome your current problem try moving the code to the next field(s) with an if statement, something like
    if me.fieldname.allowedits = true then me.fieldname.allowedits = false
    where fieldname is the name which has set the edits to true.
     
  5. tomlock2

    tomlock2 Thread Starter

    Joined:
    Nov 20, 2011
    Messages:
    49
    Actually the problem is caused since ACCESS will not allow the ALLOWEDITS property to be set to False before the record is saved. So it just ignored by Allowedits=false command in the Lost Focus event. So the solution is to do have this sort of coding in your Lost Focus event ---

    Private Sub ToPers_LostFocus()
    If Me.AllowEdits = True Then DoCmd.RunCommand acCmdSaveRecord
    Me.AllowEdits = False
    End Sub
     
  6. Sponsor

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/1032096

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice