I have a multi-tab form with several pages. In every page I have a button which I am trying to assing an onclick event procedure at runtime. For the name of the buttons I established a naming convention that is BtnAddTr# where the # varies depending on the index of the page the button is. My problem is how to assign these buttons an on click event.
The section of the code is:
For numTab = 0 To AcctMultiTab.Pages.Count - 1
'hide the tabs that are not needed
If numTab > UBound(AcctNames, 1) - 1 Then
AcctMultiTab.Pages(numTab).Visible = False
'and hide the totals by account
Me.Controls("TOTbyAcct" & numTab).Visible = False
Else
'if tab is needed, dsiplay it and set its name
With AcctMultiTab.Pages(numTab)
.Visible = True
.Caption = AcctNames(numTab + 1, 2)
' and change the text in the labels within the page
.Controls("LblTitleSbfrm" & numTab).Caption = AcctNames(numTab + 1, 2) & " - Account Register"
.Controls("LblBoxes" & numTab).Caption = " Balance in " & AcctNames(numTab + 1, 2) & " by type:"
'display the currency for account
currentAccountID = AcctNames(numTab + 1, 3)
.Controls("AcctCur" & numTab).Value = getCurrencySymbol(currentAccountID)
.Controls("AcctCur" & numTab).ForeColor = 16711808
.Controls("AcctCur" & numTab).FontWeight = 600
'now set the source row of the SbfrmDetail to a query specific to that account
'Structure the SQL string
SQLstr = "SELECT * FROM tbl_AccountRegister " & _
"WHERE ClientNUM = " & ClientIDRegister & _
" AND ClientAccountID = " & AcctNames(numTab + 1, 1) & " ORDER BY Date"
' set the record source for the subform in that page
.Controls("SbfrmDetail" & numTab).Form.RecordSource = SQLstr
' set the on click event of the Add transaction button
' so that when it is clicked it opens the AcctTransJournal form
.Controls("BtnAddTr" & numTab).OnClick = "[Event Procedure]" '**** THIS IS WHERE I NEED HELP
Our community of experts have been thoroughly vetted for their expertise and industry experience.
The Fellow title is reserved for select members who demonstrate sustained contributions, industry leadership, and outstanding performance. We will announce the experts being inducted into the Experts Exchange Fellowship during the annual Expert Awards, but unlike other awards, Fellow is a lifelong status. This title may not be given every year if there are no obvious candidates.
The Most Valuable Expert award recognizes technology experts who passionately share their knowledge with the community, demonstrate the core values of this platform, and go the extra mile in all aspects of their contributions. This award is based off of nominations by EE users and experts. Multiple MVEs may be awarded each year.