Sage MAS 90 and 200 Sage MAS 500 blogs Product Feedback Support Training
Reply
unidentified user
klindsey
Posts: 2
Registered: 12-02-2011
0

Call click event of a button from another sub

Hi,

 

I am new to customization and am trying to run a check prior to allowing a user to run an existing standard MAS 500 button.  Since you cannot customize a normal button, I was thinking of doing the following:

 

0.  Lets call the exisitng button buttonStandard and a new button buttonNew

1. Put buttonNew over buttonStandard

2. In the sub buttonNew_Click:

  a. run required check

  b. if successful call buttonStandard_Click or Forms("buttonStandard").click or something similar (not sure how to do this)

  c. if a. was not successful, raise error and return

 

Does anyone know how this can be accomplished?


Regards,
Keith

Sage MAS Partner
LouDavis
Posts: 545
Registered: 10-29-2008
0

Re: Call click event of a button from another sub

What you ask for is not available using Customizer today.  A VB button Click sub routine as well as any subroutine or function within the MAS 500 Visual Basic code is not accessible from a VB script created by Customizer.   Why you may ask?  Well the current version of Customizer was never intended to do hard core modifications to MAS 500.  That's what the SDK was created for.  Customizer's original intent was to allow users to customize the look and feel of screens, add security to these modifications and create simple vbScripts to do small things from within Customizer.

 

However, along came a few savvy users knowledgable in vbScript and the capabilities it had which pushed the bounds of what Customizer was originally designed for.    Sage has acknowledged this power user community and is in work on the next generation of Customizer which may or may have this functionality.  Maybe someone from Sage could give us a sneak peek of what to expect.  

 

For your scenario since you want to do a check, see if the Form_Save event available from within Customizer could be used for this.  I believe there is a thread on this site with some techniques on how to keep the form from saving if your check fails..  Hopefully, those who know this technique will post the information here on how to do it. 

Louis Davis MCSD, MCAD, MCITP
e2b teknologies, inc
www.e2btek.com

Contributor
mateusstock
Posts: 36
Registered: 11-01-2010
0

Re: Call click event of a button from another sub

I have done something similar to that.

 

I have a button that opens the window to create Work Orders, but I want to check if a work order already exists for that sales order line.

 

What I did was hide the original "Create WO" button and created my custom one.

 

On this custom button (also called Create WO) I do the verification I need, and it passes I call the original "Create WO" button.
Here is the code that I used:

 

 

    Sub cmdCreateWO_SPI_Click()

        Dim btnCWO
        btnCWO = Form.Controls("cmdCreateWO")

        Dim btnOWO
        btnOWO = Form.Controls("cmdOpenWO")

        If (btnOWO.enabled) Then
            MsgBox("A WO already exists for this SO Line!")
        End If

        If (btnCWO.enabled) Then
            btnCWO.SetFocus()

            'Call Enter (BIG Gambiarra)
            Dim sh
            Set sh = CreateObject("WScript.Shell")
            sh.AppActivate("Enter Sales Orders and Quotes*")
            sh.SendKeys("{ENTER}")
            Set sh = Nothing

        End If
    End Sub

 My workaround is that I set focus on the button, and then I hit "ENTER" to call the button. There are better ways to call the button, but I still have to find the example.

 

See if that helps!

Sage MAS Partner
jmiles
Posts: 34
Registered: 12-04-2008
0

Re: Call click event of a button from another sub

I've heard it's possible to do what you want by setting the original button's "Value" property to "True", but that doesn't seem to be working on my system.

Jason Miles
Technology Consultant
SGS Technology Group
http://www.sgstech.com