If only i can delete my previous post.. hmm never mind.
The code below are TESTED and working like i (or may be you) wanted it to..
Private Sub cboColor_AfterUpdate()
Dim iResponse As Integer
If Me.cboColor = "Yes" Then
'--Enabled all check box
iEnabled
Else
If iCheck = False Then
iResponse = MsgBox("YourMessange", vbYesNo, "Title")
If iResponse = vbYes Then
'--change value to False
chgFalse
'--disable all check box
iDisabled
Else
Exit Sub
End If
Else
'--All check box = True
iDisabled
End If
End If
End Sub
Private Function iCheck() As Boolean
Dim ctl As Control
iCheck = True
For Each ctl In Me.Controls
If ctl.ControlType = acCheckBox Then
If ctl.Tag = "Col" Then
If ctl.Value = True Then
iCheck = False
Exit Function
End If
End If
End If
Next
End Function
Private Sub iDisabled()
Dim ctl As Control
For Each ctl In Me.Controls
If ctl.ControlType = acCheckBox Then
If ctl.ControlType = acCheckBox Then
If ctl.Tag = "Col" Then ctl.Enabled = False
End If
End If
Next
End Sub
Private Sub iEnabled()
Dim ctl As Control
For Each ctl In Me.Controls
If ctl.ControlType = acCheckBox Then
If ctl.Tag = "Col" Then
ctl.Enabled = True
End If
End If
Next
End Sub
Private Sub chgFalse()
Dim ctl As Control
For Each ctl In Me.Controls
If ctl.ControlType = acCheckBox Then
If ctl.Tag = "col" Then
If ctl.Value = True Then ctl.Value = False
End If
End If
Next
End Sub
mie wrote:
This code untested..
Private Function iCheck() As Boolean
Dim ctl As Control
iCheck = True
For Each ctl In Me.Controls
If ctl.Tag = "Col" Then
If ctl.Value = True Then
iCheck = False
Exit Function
End If
End If
Next
End Function
Private Sub iDisabled()
Dim ctl As Control
For Each ctl In Me.Controls
If ctl.Tag = "Col" Then ctl.Enabled = False
Next
End Sub
Private Sub iEnabled()
Dim ctl As Control
For Each ctl In Me.Controls
If ctl.Tag = "Col" Then ctl.Enabled = True
Next
End Sub
Private Sub chgFalse()
Dim ctl As Control
For Each ctl In Me.Controls
If ctl.Tag = "col" Then
If ctl.Value = True Then ctl.Value = False
End If
Next
End Sub
Private Sub cboColor_AfterUpdate()
Dim iResponse As Integer
If Me.cboColor = "Yes" Then
'--Enabled all check box
iEnabled
Else
If iCheck = False Then
iResponse = MsgBox("YourMessange", vbYesNo, "Title")
If iResponse = vbYes Then
'--change value to False
chgFalse
'--disable all check box
iDisabled
Else
Exit Sub
End If
Else
'--All check box = True
iDisabled
End If
End If
End Sub
Yes I think you do need another For Next loop if you are going to warn the
user *only* if any of the CheckBoxes are checked not least because your
[quoted text clipped - 30 lines]
through the controls automatically it should mean the user gets one
prompt and not, e.g., 10.
--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...forms/201005/1