Results 1 to 3 of 3
  1. #1
    undee69 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    39

    Locking all controls in the form

    Good day everyone.



    It's me again and hopefully you can assist me once again.

    I would like to lock all the controls in the form by using a checkbox without encoding each of the control name.

    Is this possible?

    I have also tried the code below but it doesn't lock it and it is only for Textbox.

    Private Sub Form_Current()

    Dim ctrl As Control

    For Each ctrl In Me.Controls
    If TypeOf ctrl Is TextBox Then
    ctrl.Locked = True
    End If
    Next

    End Sub

  2. #2
    undee69 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    39
    Ok i have made my adjustments and it is now able to disable my form for editing. However, when i go to a new record, it doesn't allow me to edit and the checkbox is unchecked on load. It allows me to edit/add a new record if i checked and unchecked the check box.

    here is my code below:

    Private Sub Form_Current()

    Dim ctrl As Control

    For Each ctrl In Me.Controls
    If TypeOf ctrl Is TextBox Then
    ctrl.Locked = True
    End If
    Next

    'to check if the form is new, this will disable the check box
    If Me.NewRecord = True Then
    Me.Check352 = False
    Else
    Me.Check352 = True
    End If

    End Sub

  3. #3
    undee69 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    39
    I got it now. ^_^

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

Similar Threads

  1. Locking Controls
    By fotodj in forum Forms
    Replies: 5
    Last Post: 09-05-2012, 04:45 AM
  2. Locking fields in Access form
    By sk88 in forum Access
    Replies: 10
    Last Post: 06-04-2012, 01:40 PM
  3. Replies: 5
    Last Post: 12-20-2011, 06:48 PM
  4. Locking a tab in a tabbed form
    By focosi in forum Forms
    Replies: 7
    Last Post: 09-21-2011, 04:25 PM
  5. Locking Down Form
    By jo15765 in forum Forms
    Replies: 5
    Last Post: 11-16-2010, 04:44 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