[AccessD] Option Group's Control Collection - Weird Behavior

A.D. Tejpal adtp at airtelmail.in
Wed Aug 25 10:54:42 CDT 2010


Something to alleviate current quiet phase in AccessD
====================================

    It is observed that if subcontrols (say toggle buttons) belonging to an option group are accessed via For Each loop, there is no problem so long as original position of these subcontrols is not disturbed.

    However, if programmatic manipulation (say by adding 1 twip to subcontrol's top property) is attempted, only some of the subcontrols get acted upon (some amongst them multiple times) while others get skipped. Total number of hits still adds up to the total count of such subcontrols. This weird pattern persists even if the subcontrols are accessed via item index, using For Counter = 0 to CollectionCount -1 (instead of for each loop). 

    Sample code used for conducting such a test is given below (Access 2003 desktop on Win XP):

' Sample code in VBA module of form
' having an option group named Opg_A
'==========================
Private Sub P_OpnGrpTest()
    Dim ct As Access.Control
    
    For Each ct In Me.Opg_A.Controls
        ct.top = ct.top + 1
        Debug.Print ct.Name, ct.top
    Next
    
    Set ct = Nothing
End Sub
'==========================

    Interested members might like to examine and offer their considered views regarding:
    (a) The likely explanation for such behavior.
    (b) Suggested optimum solution.

    I have two alternative solutions in mind. These are not being included at this stage so that the topic gets fresh treatment in a wider perspective.

Best wishes,
A.D. Tejpal
------------


More information about the AccessD mailing list