0

I am working on Infopath and VBA and facing a trivial issue. I have tried searching on this and found a few examples but could not comprehend them correctly (being a novice).

I will really appreciate if any one can push me in the right direction.

I am trying to accomplish executing code for four buttons (button1,2,3,4) by clicking a button called MasterSumbit

I have the event handlers loaded in the InternalStartup section

    Private Sub InternalStartup(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Startup
    AddHandler DirectCast(EventManager.ControlEvents("Button1"), ButtonEvent).Clicked, AddressOf Button1_Clicked
    AddHandler DirectCast(EventManager.ControlEvents("Button2"), ButtonEvent).Clicked, AddressOf Button2_Clicked
    ...and such for button 3 and 4
    AddHandler DirectCast(EventManager.ControlEvents("MasterSubmit"), ButtonEvent).Clicked, AddressOf MasterSubmit_Clicked
    End Sub

This is the code for the click event on the MasterSubmit Button

    Public Sub MasterSubmit_Clicked(ByVal sender As Object, ByVal e As ClickedEventArgs)

    Button1_Clicked.click()
    Button2_Clicked.click()
    Button3_Clicked.click()
    Button4_Clicked.click()

    End Sub

I get the following errors for each button

Argument not specified for parameter 'e' of 'Public Sub Button1_Clicked(sender As Object, e As Microsoft.Office.InfoPath.ClickedEventArgs)'.
Argument not specified for parameter 'sender' of 'Public Sub Button1_Clicked(sender As Object, e As Microsoft.Office.InfoPath.ClickedEventArgs)'.

Thanks in anticipation

Tim Williams
  • 154,628
  • 8
  • 97
  • 125
user2204330
  • 13
  • 1
  • 1
  • 4
  • Are you adding the four buttons at runtime? If not, can't you just do `Private Sub AnyButton_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click, Button2.Click, Button3.Click, Button4.Click`? – Doug Glancy Mar 24 '13 at 15:10
  • Also, you should re-tag your question to VB.Net. It's definitely not VBA :) . – Doug Glancy Mar 24 '13 at 15:15
  • I have tried putting this after the internal startup section but does not work. I am pretty sure I am doing it wrong! – user2204330 Apr 27 '13 at 06:30

2 Answers2

1

Try this:

Public Sub MasterSubmit_Clicked(ByVal sender As Object, ByVal e As ClickedEventArgs)

 Button1_Clicked.click(sender, e)
 Button2_Clicked.click(sender, e)
 Button3_Clicked.click(sender, e)
 Button4_Clicked.click(sender, e)

End Sub
Leo Chapiro
  • 13,678
  • 8
  • 61
  • 92
0

Would (inside the Sub for Master button) this not work?

Button2.PerformClick()
Button3.PerformClick() etc....

Hope I helped.

SolaGratia
  • 309
  • 4
  • 18