View Single Post
  #4  
Old May 20th, 2010, 12:38 PM posted to microsoft.public.access.forms
mie via AccessMonster.com
external usenet poster
 
Posts: 9
Default looping through controls - for each ... next

Sorry, i didnt go through your code to the end. So, DONT USE THE CODE I
SUGGESTED.
I''ll be back when i'am finished.

mie wrote:
If i understand correctly, what you want to do is, if user select 'YES', edit
data then suddenly
change to 'NO'. So, all changes should be cancel, right?

This code untested..i just copy n paste your code and add a few line.

Dim ctl As Control

For Each ctl In Me
If ctl.Tag = "col" Then
If Me.cboColor.Value = "Yes" Then
ctl.Enabled = True
Else
If ctl.Value = False Then 'nothing has been checked;
disable the controls

ctl.Enabled = False

'--Add this Line.
If ctl.Value = True Then ctl.Value = False

Else 'something has been checked; tell user it will be
deleted
iresponse = MsgBox("Changing this from Yes will delete
the information in the " & _
"related fields." & _
Chr(13) & Chr(13) & "Continue?", 4 + 48 + 256, "Delete
confirmation")
If iresponse = 7 Then ' user said
No
Me.cboColor.Value = "Yes"
Exit Sub
Else ' user said Yes
ctl.Value = Null
ctl.Enabled = False
End If
End If
End If
End If
Next
Set ctl = Nothing

Private Sub cboColor_AfterUpdate()

[quoted text clipped - 6 lines]
disable the controls
ctl.Enabled = False

'-----Put this line
If ctl.Value=True Then ctl.Value = False
Else 'something has been checked; tell user it will be
deleted

[quoted text clipped - 18 lines]

End Sub


If the user checks selects 'Yes' from a combo box, I'd like to enable
a group of check boxes (all have tag property "col"). If the user

[quoted text clipped - 43 lines]

Thank you.


--
Message posted via http://www.accessmonster.com