S
Saintor
The following function works when used directly from a form. It locks
controls depending on a value stored in the tag property. Called from a
button on a subform, it does not work [UpdFormPropsLock(me.name, 3, true,
0)]. TIA.
Public Function UpdFormPropsLock(sForm As String, sLockLevel As Integer,
bSign As Boolean, Optional iJump As Integer) As Boolean
Dim sM1 As String
On Error Resume Next
If CurrentUserInGroup("Quality 1") = False And CurrentUserInGroup("Quality
2") = False And CurrentUserInGroup("Admins") = False Then
sM1 = "You have not the authorization to perform this operation."
If sLang = "F" Then sM1 = DLookup("CtlValue_FR", "tblLang",
"FormName='00056'")
MsgBox sM1, vbExclamation
Exit Function
End If
Dim doc As Document
Dim frm As Form
Dim ctl As Control
Dim Prop As Property
Dim sA As String
Set frm = Forms(sForm)
For Each ctl In frm.Controls
For Each Prop In ctl.Properties
Select Case ctl.ControlType
Case acCheckBox, acOptionGroup, acTextBox, acComboBox, acListBox
If Prop.Name = "Tag" Then
If IsNull(Prop.Value) = True Or Prop.Value = "" Then
GoTo goto_next
ElseIf Prop.Value > 0 And Prop.Value <= CStr(sLockLevel) Then
ctl.Locked = True
ElseIf Prop.Value > CStr(sLockLevel) And Prop.Value <= "9" Then
ctl.Locked = False
End If
End If
Case acCommandButton
If Prop.Name = "Tag" Then
If Prop.Value > "0" And Prop.Value <= CStr(sLockLevel) Then
If bSign = True Then frm!LockLevel.SetFocus
ctl.Enabled = False
ElseIf Prop.Value > CStr(sLockLevel) And Prop.Value < "9" Then
If bSign = True Then frm!LockLevel.SetFocus
ctl.Enabled = True
End If
End If
Case acSubform
If Prop.Name = "Tag" Then
If Prop.Value <= CStr(sLockLevel) Then
ctl.Enabled = False
ElseIf Prop.Value > CStr(sLockLevel) Then
ctl.Enabled = True
End If
End If
End Select
goto_next:
Next Prop
Next ctl
frm!LockLevel = sLockLevel
frm.Refresh
UpdFormPropsLock = True
Set Prop = Nothing
Set ctl = Nothing
Set frm = Nothing
Set doc = Nothing
End Function
controls depending on a value stored in the tag property. Called from a
button on a subform, it does not work [UpdFormPropsLock(me.name, 3, true,
0)]. TIA.
Public Function UpdFormPropsLock(sForm As String, sLockLevel As Integer,
bSign As Boolean, Optional iJump As Integer) As Boolean
Dim sM1 As String
On Error Resume Next
If CurrentUserInGroup("Quality 1") = False And CurrentUserInGroup("Quality
2") = False And CurrentUserInGroup("Admins") = False Then
sM1 = "You have not the authorization to perform this operation."
If sLang = "F" Then sM1 = DLookup("CtlValue_FR", "tblLang",
"FormName='00056'")
MsgBox sM1, vbExclamation
Exit Function
End If
Dim doc As Document
Dim frm As Form
Dim ctl As Control
Dim Prop As Property
Dim sA As String
Set frm = Forms(sForm)
For Each ctl In frm.Controls
For Each Prop In ctl.Properties
Select Case ctl.ControlType
Case acCheckBox, acOptionGroup, acTextBox, acComboBox, acListBox
If Prop.Name = "Tag" Then
If IsNull(Prop.Value) = True Or Prop.Value = "" Then
GoTo goto_next
ElseIf Prop.Value > 0 And Prop.Value <= CStr(sLockLevel) Then
ctl.Locked = True
ElseIf Prop.Value > CStr(sLockLevel) And Prop.Value <= "9" Then
ctl.Locked = False
End If
End If
Case acCommandButton
If Prop.Name = "Tag" Then
If Prop.Value > "0" And Prop.Value <= CStr(sLockLevel) Then
If bSign = True Then frm!LockLevel.SetFocus
ctl.Enabled = False
ElseIf Prop.Value > CStr(sLockLevel) And Prop.Value < "9" Then
If bSign = True Then frm!LockLevel.SetFocus
ctl.Enabled = True
End If
End If
Case acSubform
If Prop.Name = "Tag" Then
If Prop.Value <= CStr(sLockLevel) Then
ctl.Enabled = False
ElseIf Prop.Value > CStr(sLockLevel) Then
ctl.Enabled = True
End If
End If
End Select
goto_next:
Next Prop
Next ctl
frm!LockLevel = sLockLevel
frm.Refresh
UpdFormPropsLock = True
Set Prop = Nothing
Set ctl = Nothing
Set frm = Nothing
Set doc = Nothing
End Function