Results 1 to 6 of 6
  1. #1
    Cazca is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2015
    Posts
    28

    Lock column in record based of another column

    Hello all.



    I'm trying to lock field1 for edits if field5 is true. However, I need field1 to remain locked for all other records.

    I've successfully done this with a macro under On Click, but it unlocks the column for all records:

    If [field5]=0 then SetProperty
    Control Name field1
    Property Locked
    Value False

    This can be accomplished with VBA, just more familiar with macros

  2. #2
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    if you are using a bound form in continuous view there is no easy way I know of to lock some and unlock other fields. If you want this kind of functionality your form or subform (whichever it is) would have to be in single record view.

  3. #3
    Cazca is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2015
    Posts
    28
    It's a split form with datasheet on the bottom.

    It would seem an easy argument, if field5 is false, field1 is editable.

    Thanks for the reply. I'm going to continue to search and will post back of I find something.

    Any other suggestions are welcome.

  4. #4
    vicsaccess's Avatar
    vicsaccess is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Apr 2015
    Posts
    451
    i believe the method you are looking for is "enabled". try something like
    Code:
    Private Sub Form_AfterUpdate()
        If ([field5]) = -1 Then
            [field1].Enabled = False
        Else
            [field1].Enabled = True
        End If
    End Sub

  5. #5
    Cazca is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2015
    Posts
    28
    Quote Originally Posted by vicsaccess View Post
    i believe the method you are looking for is "enabled". try something like
    Code:
    Private Sub Form_AfterUpdate()
        If ([field5]) = -1 Then
            [field1].Enabled = False
        Else
            [field1].Enabled = True
        End If
    End Sub
    I think this is exactly what I'm looking for. I need it to run this argument before someone would even be able to edit field1.

    So I put your code into On Click and got this error:

    Compile error:
    Method or data member not found
    (and it is highlighting '.Enabled =' that is right after Then.)

  6. #6
    vicsaccess's Avatar
    vicsaccess is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Apr 2015
    Posts
    451
    i would put it as the afterupdate of [field5]

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

Similar Threads

  1. Replies: 4
    Last Post: 12-29-2015, 03:25 PM
  2. Add additional Column based on a column value
    By deepanadhi in forum Queries
    Replies: 7
    Last Post: 05-31-2012, 02:02 AM
  3. Replies: 1
    Last Post: 03-14-2011, 10:04 AM
  4. Replies: 1
    Last Post: 04-15-2010, 02:07 AM
  5. inserting values in column based another column
    By wasim_sono in forum Database Design
    Replies: 1
    Last Post: 06-27-2006, 05:23 AM

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