Option Compare Database
Option Explicit
Private Sub Form_Current()
[COLOR="Red"]Call U1_Test[/COLOR]
[COLOR="SeaGreen"]' U1_AfterUpdate '-- instead of this one[/COLOR]
A_AfterUpdate
P1_AfterUpdate
B_AfterUpdate
P2_AfterUpdate
C_AfterUpdate
U2_AfterUpdate
Inactive_AfterUpdate
End Sub
Private Sub fDisableGrp(strGroup As String)
Dim Ctl As Control
For Each Ctl In Me.Controls
Select Case Ctl.ControlType
Case acTextBox, acComboBox, acOptionGroup, acListBox
If fGetGroup(Ctl.Name, strGroup) Then Ctl.Enabled = False
End Select
Next Ctl
End Sub 'fLockGrp
Private Sub fEnableGrp(strGroup As String)
Dim Ctl As Control
For Each Ctl In Me.Controls
Select Case Ctl.ControlType
Case acTextBox, acComboBox, acOptionGroup, acListBox
If fGetGroup(Ctl.Name, strGroup) Then Ctl.Enabled = True
End Select
Next Ctl
End Sub 'fUnLockGrp
Private Function fGetGroup(strCtrlName As String, strGroup As String) As Boolean
Dim str1 As String
str1 = Mid(strCtrlName, 1, 2)
fGetGroup = False
If str1 = strGroup Then fGetGroup = True
End Function 'fGetGroup
Private Sub U1_AfterUpdate()
[COLOR="Red"]Call U1_Test[/COLOR]
End Sub
[COLOR="Red"]Private Sub U1_Test()
If Me.U1 Then
Call fEnableGrp("G1")
Else
Call fDisableGrp("G1")
End If
End Sub[/COLOR]
Private Sub A_AfterUpdate()
If Me.A Then
Call fEnableGrp("G2")
Else
Call fDisableGrp("G2")
End If
End Sub
Private Sub P1_AfterUpdate()
If Me.P1 Then
Call fEnableGrp("G3")
Else
Call fDisableGrp("G3")
End If
End Sub
Private Sub B_AfterUpdate()
If Me.B Then
Call fEnableGrp("G4")
Else
Call fDisableGrp("G4")
End If
End Sub
Private Sub P2_AfterUpdate()
If Me.P2 Then
Call fEnableGrp("G5")
Else
Call fDisableGrp("G5")
End If
End Sub
Private Sub C_AfterUpdate()
If Me.C Then
Call fEnableGrp("G6")
Else
Call fDisableGrp("G6")
End If
End Sub
Private Sub U2_AfterUpdate()
If Me.U2 Then
Call fEnableGrp("G7")
Else
Call fDisableGrp("G7")
End If
End Sub