Results 1 to 12 of 12
  1. #1
    Join Date
    Apr 2006
    Posts
    7

    Unanswered: Locking Individual Fields

    I have created a database and wish to lock individual fields so that once information has been entered, it cannot be changed.

    I have done this through an event procedure...

    Private Sub Form_Current()
    Me.sample.Enabled = Me.NewRecord
    End Sub

    Private Sub sample_BeforeUpdate(Cancel As Integer)

    End Sub


    This was successful for the desired field, however, when I went to copy this event procedure for other fields (by simply changing the field name in the procedure) I received error messages or a run time error.

    Please help!


    Error message reads:

    the expression ONCURRENT you entered as the event property setting produced the following error: ambiguous name detected: FORM_CURRENT

    or runtime error:

    '2164' you can't disable a control while it has focus.

  2. #2
    Join Date
    Aug 2004
    Location
    NY
    Posts
    113
    I would try something like this on the current of the form

    If Me.NewRecord Or Not Me!LockE Then
    Me.txtSecE.Locked = False
    Me.txtSecF.Locked = False
    else
    Me.txtSecE.Locked = True
    Me.txtSecF.Locked = True
    end if
    ======================
    Levent
    Access 3

  3. #3
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    Uh yes ... You cannot lock or disable a control that has the focus. You have to set the focus to another control and then do your lock/disable ...
    Back to Access ... ADO is not the way to go for speed ...

  4. #4
    Join Date
    Apr 2006
    Posts
    7
    I tried..

    If Me.NewRecord Or Not Me!LockE Then
    Me.txtSecE.Locked = False
    Me.txtSecF.Locked = False
    else
    Me.txtSecE.Locked = True
    Me.txtSecF.Locked = True
    end if

    No luck, any other suggestions?

    How can I change the focus to another control?

  5. #5
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926

    setfocus

    To set the focus to another field -

    me.myotherfield.setfocus
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  6. #6
    Join Date
    Apr 2006
    Posts
    7
    do i set the focus in the current, before or after update, etc.?

  7. #7
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    Prior to acting on the control. Basically, whereever you're gonna lock or disable, set the focus to another control ...
    Back to Access ... ADO is not the way to go for speed ...

  8. #8
    Join Date
    Apr 2006
    Posts
    7
    I have attempted several of these suggestions although have been unsuccessful.

    I am fairly new to Access and cant seem to get around this problem.

    How would you suggest I put this into the event procedure?
    And where?

    For example, I have two fields- issue and category.

    I have successfully locked the issue field, but cannot seem to do the same for the category.

    Any help would be greatly appreciated!

  9. #9
    Join Date
    Aug 2004
    Location
    NY
    Posts
    113
    How are you locking this? with a command, toggle or check box?
    Do you want to lock both at the same time?
    ======================
    Levent
    Access 3

  10. #10
    Join Date
    Apr 2006
    Posts
    7
    I want to lock the information once it is entered and the user moves to the next record. The goal is to ensure that vital information is not changed.

    The way that I have locked the one field thus far is through an event procedure.

    It works great on the one field, the only problem is that it will not allow me to copy the event procedure for multiple fields.

    I have tried to enable/disable, setfocus... nothing seems to be working.

    Is there another way to go about locking the individual fields?

  11. #11
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    Your problem begs the question of what are you going to do when users enter incorrect data? And they will!
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  12. #12
    Join Date
    Apr 2006
    Posts
    7
    The fields that I am trying to lock are combo boxes which have a value list of options. The way that I have locked the one field, is that the field cannot be changed once the user moves on to the next record. Therefore, the field boxes can be changes up to the point that the user either exits the program or moves to the next record.

Posting Permissions

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