Lock / Unlock Bound Controls...

You can use this Function to lock/unlock all the *bound* controls on a Form.  Copy/paste this Function into a Module.  Remember, do not name the Module the same as the Function.
Private Sub Form_Current()

     If (Me.txtStatusID) = "C" Then
         fncLockUnlockControls Me, True  'Locked
     Else
         fncLockUnlockControls Me, False   'Unlocked
     End If

End Sub
To call this Function you need a trigger, in the example txtStatusID is used, and then place something like the below in the On_Current event of your form...
The difficult I do immediately, the impossible takes a little bit longer.
Public Function fncLockUnlockControls(frm As Form, LockIt As Boolean)
'From http://www.access-diva.com/tips.html
 
     'Lock or unlock all data-bound controls on form,
     'depending on the value of : True = lock; False = unlock.
     'Posted in the Newsgroups by Dirk Goldgar Access MVP 2005
 
     On Error GoTo Err_fncLockUnlockControls
     Const conERR_NO_PROPERTY = 438
 
     Dim ctl As Control
 
     For Each ctl In frm.Controls
         With ctl
             If Left(.ControlSource & "=", 1) <> "=" Then
                 .Locked = LockIt
                 .Enabled = True
             End If
         End With
Skip_Control: 'come here from error if no .ControlSource property
Next ctl
 
Exit_fncLockUnlockControls:
     Exit Function
 
Err_fncLockUnlockControls:
     If Err.Number = conERR_NO_PROPERTY Then
         Resume Skip_Control
     Else
         MsgBox "Error " & Err.Number & ": " & Err.Description
         Resume Exit_fncLockUnlockControls
End If
 
End Function 
VBA
Tips (Main)
Home
Creating a Multi-Value field using Alphabet
Copy Fields Down from above Record
Loop thru records and OutPutTo seperate .RTF or .PDF
Modified Spell Check
Code Snippets
Loop while renumbering two columns
Create a Table with Dynamic Field Names
Snippets for Exporting to Excel
Log Field Changes
Log Record Deletions
Check for Duplicate Values
ValidateData()
ClearClipboard()
Selecting an Excel Worksheet from Access
Send eMail to Multiple Recipients
Cancel Save in a Bound Form
Automatically Send eMail Notifications
fFindBookmark()
Looping Records to Send eMail
fxlFindReplace()
fMouseOverCurrent()
fHighlightRequiredControls()
Check if Table Exists
fAmortization()
Insert (or Remove) Blank Line
This site uses cookies to collect data on usage. By continuing to browse this site you consent to this policy. Find out more here.