How do I run this code?

D

DJJ

I want to have the option to lock and unlock specific records on a form.

I took the following procedure from the MSDN site but I can't figure out
which events to use or what arguments to specify (if any) in order to run
this procedure. Everything I try just produces multiple errors; does anyone
have any suggestions on how to run this code?


Sub ToggleControl(frm As Form)

Dim intI As Integer, intCanEdit As Integer
Const conTransparent = 0
Const conWhite = 16777215
For Each ctl In frm.Controls
With ctl
Select Case .ControlType
Case acLabel
If .SpecialEffect = acEffectShadow Then
.SpecialEffect = acEffectNormal
.BorderStyle = conTransparent
intCanEdit = True
Else
.SpecialEffect = acEffectShadow
intCanEdit = False
End If
Case acTextBox
If .SpecialEffect = acEffectNormal Then
.SpecialEffect = acEffectSunken
.BackColor = conWhite
Else
.SpecialEffect = acEffectNormal
.BackColor = frm.Detail.BackColor
End If
End Select
End With
Next ctl
If intCanEdit = False Then
With frm
.AllowAdditions = False
.AllowDeletions = False
.AllowEdits = False
End With
Else
With frm
.AllowAdditions = True
.AllowDeletions = True
.AllowEdits = True
End With
End If
End Sub
 
D

Douglas J Steele

Create a command button, and in the Event Procedure for that button, put
code like:

Private Sub Command1_Click()

Call ToggleControl(Me)

End Sub
 
D

DJJ

Thanks!

Douglas J Steele said:
Create a command button, and in the Event Procedure for that button, put
code like:

Private Sub Command1_Click()

Call ToggleControl(Me)

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top