Set multiple cmd boxes to enabled = true

Posted on 2008-11-13
Last Modified: 2013-12-25
Hi Experts,
Fairly simple one, but one that is bugging me...

I have 100 cmd boxes cmd1, cmd2, cmd3..... cmd100 upon clicking the rest button i want all of the cmdbuttons to set enabled = true. i know i could go through each one putting cmdX.enabled = true but it seems a bit messy. is there a way to do it in some kind of loop? e.g.:
for x = 1 to 100
         cmd & x.enabled = true

Thanks guys
Regards Matt
Question by:Matty_mca
    LVL 11

    Accepted Solution

    This will enable every button on the form:

    Dim objControls
        For Each objControls In Me.Controls
            If TypeName(objControls) = "CommandButton" Then objControls.Enabled = True

    If you need to limit the enabling to specific buttons you could perhaps put a value in their Tag property and check that before enabling them.

    Author Closing Comment

    Thanks Antagony1960.
    Tag property also worked a treat

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Suggested Solutions

    Title # Comments Views Activity
    System.badimageFormatException error 3 42
    Open Report with Multiple Criteria 9 57
    Port V2 16 35
    VBA error replacing data 6 29
    I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
    If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
    Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
    Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now