Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2004
    Location
    U.S.
    Posts
    12

    Unanswered: Referencing an event subroutine

    Suppose I have a control named "AbcXyz"
    If I wanted to access some property like AbcXyz.Visible, I could write
    Code:
    Dim Str1, Str2 as String
    Str1="Abc"
    Str2="Xyz"
    Me(Str1 & Str2).Visible = False
    ...using concatenated strings to construct the name of the control, and the Me collection to reference it.

    But if the property is an event (say, an AfterUpdate event) it will have a subroutine in the code module that looks like:
    Code:
    Private Sub AbcXyz_AfterUpdate()
      'DoSomething
    End Sub
    ...and I invoke it (via code, when not triggered by an actual event) simply by using its name:
    Code:
    AbcXyz_AfterUpdate
    ...assuming I know explicitly that this is what I want at compile-time.

    The question is: How can I use the expression < Str1 & Str2 & "_AfterUpdate" > to invoke execution of this very same subroutine, where Str1 and Str2 might not be known until run-time, in order to choose one AfterUpdate event from a whole set of related controls?
    Last edited by AJS; 02-28-04 at 05:08.

  2. #2
    Join Date
    Jan 2004
    Posts
    184

    Re: Referencing an event subroutine

    I don't think you can unless you are using a sciripting language that compiles at runtime.

    VB is compiled before runtime.
    In abundance of water only the fool is thirsty. Bob Marley.

  3. #3
    Join Date
    Feb 2004
    Location
    U.S.
    Posts
    12
    Thanks for responding. I got around it with a Select Case mechanism.
    --Andy

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •