Results 1 to 4 of 4
  1. #1
    oriongate is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Jul 2011
    Posts
    7

    Talking Problem with locking and unlocking memofields with a button

    Hi All,
    I am relatively new to Access. I am wondering if someone can help me to overcome a problem that I have encountered in a database that I have inherited at work. I have a mask whose fields are locked and activated by a button. The code is

    Private Sub Interruttore28_Click()
    If Forms("Elenco DIA").Controls("Num").Locked = True Then
    Forms("Elenco DIA").Controls("Num").Locked = False
    Forms("Elenco DIA").Controls("Prot").Locked = False
    Forms("Elenco DIA").Controls("Data").Locked = False
    Forms("Elenco DIA").Controls("Indirizzo").Locked = False
    Forms("Elenco DIA").Controls("Titolare Denuncia").Locked = False
    Forms("Elenco DIA").Controls("Interruttore28").Caption = "Blocca Inserimento"
    Else
    Forms("Elenco DIA").Controls("Num").Locked = True
    Forms("Elenco DIA").Controls("Prot").Locked = True
    Forms("Elenco DIA").Controls("Data").Locked = True
    Forms("Elenco DIA").Controls("Indirizzo").Locked = True
    Forms("Elenco DIA").Controls("Titolare Denuncia").Locked = True
    Forms("Elenco DIA").Controls("Interruttore28").Caption = "Sblocca Inserimento"
    End If
    End Sub



    The code works fine.
    Then I had to add two memo field (Descrizione, Note) to the underlining table. I then modified the mask and I changed the code like this:

    Private Sub Interruttore28_Click()
    If Forms("Elenco DIA").Controls("Num").Locked = True Then
    Forms("Elenco DIA").Controls("Num").Locked = False
    Forms("Elenco DIA").Controls("Prot").Locked = False
    Forms("Elenco DIA").Controls("Data").Locked = False
    Forms("Elenco DIA").Controls("Descrizione").Disabled = False
    Forms("Elenco DIA").Controls("Note").Disabled = False
    Forms("Elenco DIA").Controls("Indirizzo").Locked = False
    Forms("Elenco DIA").Controls("Titolare Denuncia").Locked = False
    Forms("Elenco DIA").Controls("Interruttore28").Caption = "Blocca Inserimento"
    Else
    Forms("Elenco DIA").Controls("Num").Locked = True
    Forms("Elenco DIA").Controls("Prot").Locked = True
    Forms("Elenco DIA").Controls("Data").Locked = True
    Forms("Elenco DIA").Controls("Descrizione").Disabled = True
    Forms("Elenco DIA").Controls("Note").Disabled = True
    Forms("Elenco DIA").Controls("Indirizzo").Locked = True
    Forms("Elenco DIA").Controls("Titolare Denuncia").Locked = True
    Forms("Elenco DIA").Controls("Interruttore28").Caption = "Sblocca Inserimento"
    End If
    End Sub

    But, now, when I press the button the system gives me the following error:
    Runtime Error "438"
    Property or method not supported by the object.

    I would really apreciate I someone can suggest to me how can I avoid this problem and get the code right!

    Thanks

    Oringate
    Last edited by oriongate; 07-15-2011 at 03:42 AM. Reason: Solved

  2. #2
    oriongate is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Jul 2011
    Posts
    7
    Hi all,
    There was nothing wrong in how I modified the original code. My mistake was that I did not put in the NOME ELEMENTO situated in the ALTRO tab (I am sorry I do not know the names of these access form elements in English) the same name that appears in the OORIGINE CONTROLLO in the DATI tab. Writing the same name in this two fields seam to have made all the difference in my case.
    Bye
    Oriongate

  3. #3
    SteveH2508 is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Sep 2010
    Location
    Chelsea, London, England
    Posts
    117
    .Disabled is not a property of a textbox.

    .Enabled is the property you need.

    Why use .Enabled for some textboxes and .Locked for others?

  4. #4
    oriongate is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Jul 2011
    Posts
    7

    Correction to my original post

    Hi SteveH2508
    The code I posted in my original post had a few mistakes in it. I realised it after I read your post. I have to be more carefull the next time if I want to receive help from the community.

    The original code I found was:

    rivate Sub Interruttore28_Click()
    If Forms("Elenco DIA").Controls("Num").Locked = True Then
    Forms("Elenco DIA").Controls("Num").Locked = False
    Forms("Elenco DIA").Controls("Prot").Locked = False
    Forms("Elenco DIA").Controls("Data").Locked = False
    Forms("Elenco DIA").Controls("Indirizzo").Locked = False
    Forms("Elenco DIA").Controls("Titolare Denuncia").Locked = False
    Forms("Elenco DIA").Controls("Interruttore28").Caption = "Blocca Inserimento"
    Else
    Forms("Elenco DIA").Controls("Num").Locked = True
    Forms("Elenco DIA").Controls("Prot").Locked = True
    Forms("Elenco DIA").Controls("Data").Locked = True
    Forms("Elenco DIA").Controls("Indirizzo").Locked = True
    Forms("Elenco DIA").Controls("Titolare Denuncia").Locked = True
    Forms("Elenco DIA").Controls("Interruttore28").Caption = "Sblocca Inserimento"
    End If
    End Sub

    I simply modified it to:

    Private Sub Interruttore28_Click()
    If Forms("Elenco DIA").Controls("Num").Locked = True Then
    Forms("Elenco DIA").Controls("Num").Locked = False
    Forms("Elenco DIA").Controls("Prot").Locked = False
    Forms("Elenco DIA").Controls("Data").Locked = False
    Forms("Elenco DIA").Controls("Descrizione").Locked = False
    Forms("Elenco DIA").Controls("Note").Locked = False
    Forms("Elenco DIA").Controls("Indirizzo").Locked = False
    Forms("Elenco DIA").Controls("Titolare Denuncia").Locked = False
    Forms("Elenco DIA").Controls("Interruttore28").Caption = "Blocca Inserimento"
    Else
    Forms("Elenco DIA").Controls("Num").Locked = True
    Forms("Elenco DIA").Controls("Prot").Locked = True
    Forms("Elenco DIA").Controls("Data").Locked = True
    Forms("Elenco DIA").Controls("Descrizione").Locked = True
    Forms("Elenco DIA").Controls("Note").Locked= True
    Forms("Elenco DIA").Controls("Indirizzo").Locked = True
    Forms("Elenco DIA").Controls("Titolare Denuncia").Locked = True
    Forms("Elenco DIA").Controls("Interruttore28").Caption = "Sblocca Inserimento"
    End If
    End Sub

    At first it would not work and i would get...

    Runtime Error "438"
    Property or method not supported by the object.

    ...all the time.

    But when I realised that I had to put the same name in the NOME ELEMENTO situated in the ALTRO tab as the name that appears in the ORIGINE CONTROLLO in the DATI tab, everything started to work fine.
    At the end of the day it turned to be a very simple change to make after all.
    thanks
    oriongate

Please reply to this thread with any new information or opinions.

Similar Threads

  1. locking it down
    By BAX5127 in forum Access
    Replies: 0
    Last Post: 03-22-2011, 06:51 PM
  2. Locking entries
    By jo15765 in forum Forms
    Replies: 11
    Last Post: 11-16-2010, 07:54 AM
  3. Locking fields
    By Icewolf0927 in forum Forms
    Replies: 3
    Last Post: 09-23-2010, 12:01 PM
  4. Problem on Option Button
    By cwwaicw311 in forum Forms
    Replies: 2
    Last Post: 02-10-2010, 10:44 AM
  5. Replies: 1
    Last Post: 02-05-2010, 07:25 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums