Advertisement

07.18.2008 at 09:45AM PDT, ID: 23577439
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.2

How can I assign an onclick event on a command button at runtime?

Asked by jpav in Access Coding/Macros

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 HELPStart Free Trial
 
Loading Advertisement...
 
[+][-]07.18.2008 at 10:35AM PDT, ID: 22038044

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Access Coding/Macros
Sign Up Now!
Solution Provided By: JDettman
Participating Experts: 1
Solution Grade: A
 
 
 
Loading Advertisement...
20081112-EE-VQP-44 / EE_QW_2_20070628