A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

looping through controls - for each ... next



 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old May 20th, 2010, 06:04 AM posted to microsoft.public.access.forms
Kurt Heisler
external usenet poster
 
Posts: 8
Default looping through controls - for each ... next

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
selects 'No', I'd like to disable them but, if any are checked, tell
the user data will be deleted and then set the checkboxes = Null
(assuming the user says okay). My current code triggers the prompt for
*each* check box that's checked, rather then looping through them
automatically. Do I need to another "For each ..." clause after the
first Else statement?

###

Private Sub cboColor_AfterUpdate()

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
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

End Sub

###

Thank you.
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 09:22 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.