How can I activate a button control that does not have a Value property

Posted on 2004-11-26
Last Modified: 2010-05-02

I have an application that uses a user-defined OCX enhanced button.  I want the On_Click event of one of these buttons to activate the On_Click event of another button, although this particular command button does not have a Value property - Using the conventional vb button control I could simply say

cmdButton2.Value = True

 in order to activate it - how can I achieve same in my scenario.

Thanks in advance
Question by:icontroldev
    LVL 32

    Accepted Solution

    You can call the method directly:

    Sub cmdButton1_Click()
        Call cmdButton2_Click()

    End Sub
    LVL 10

    Expert Comment

    A more oo approach would be to create a public method, place the button click event handler code into it and call it from both button click events. The other advantage to this is that you won't get tangled up in your error handling routines if you use vb "bubble-up" error handling.
    LVL 10

    Expert Comment

    Well Erick37's approach was correct, but I believe my answer has merit too.
    LVL 32

    Expert Comment

    Actually my approach was just poor programming practice

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
    I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
    As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
    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…

    745 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

    13 Experts available now in Live!

    Get 1:1 Help Now