Results 1 to 31 of 31

Thread: How to loop through all INDIVIDUAL controls on a form especially with control arrays

Threaded View

  1. #3
    Frenzied Member Gruff's Avatar
    Join Date
    Jan 2014
    Location
    Scappoose Oregon USA
    Posts
    1,293

    Re: How to loop through all INDIVIDUAL controls on a form especially with control arr

    It has been a while, but I think you can just set the form enabled to true or false as needed. While the controls do not visibly reflect disabled states they are not selectable. If all you are doing is preventing the user from interrupting a process that takes time this might be the best soution.

    If that doesn't work then you can write a single procedure to do the job.
    Realize though that not all controls have an enabled property so you have to allow for that.

    Code:
    Public Sub Enable_All(byval State as boolean)
      On error resume next
      For each C as control in Me.Controls
        C.enabled =State
      Next C
      On error goto 0
    End Sub
    You can shorten that by toggling the enable state by using NOT
    Code:
    Public Sub Toggle_Enabled()
      On error resume next
      For each C as control in Me.Controls
        C.enabled = Not(C.enabled)
      Next C
      On error goto 0
    End Sub
    Regarding detecting Control arrays. This was discussed in depth on another forum over 16 years ago.
    Bottom line was that there was no way to automatically determine if a control is a control array.

    You could create a sub class that has a custom property or use the tag property to identify them
    or even simpler use a control naming convention that identifies them as control arrays.
    e.g. txtBarCodeCA, btnTotalsCA, etc...
    Last edited by Gruff; Jul 23rd, 2016 at 07:41 AM.
    Burn the land and boil the sea
    You can't take the sky from me


    ~T

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width