Using control variable in a call

  • Thread starter Thread starter Bill
  • Start date Start date
B

Bill

Given the code below where a user's selection
from a combo is being inserted into a text box
using a control varible. Can that control variable
also be used in some sort of calling syntax to
call the AfterUpdate event procedure that
corresponds to whatever text box is involved?

Dim tbcntl as control
Dim strWrk() as String

If Not tbcntl Is Nothing Then '
Control set?
tbcntl.SetFocus
' Need text box to have the focus
strWrk = Split(Me.cmboNameList.Column(0), ",") ' Okay, capture the
choice
tbcntl.Value = strWrk(1) & " " & strWrk(0) ' Format
user's choice
Me.cmboNameList.Visible = False ' Hide
until needed again
End If

Code needs to be compatible with A2K.

Thanks,
Bill
 
Bill said:
Given the code below where a user's selection
from a combo is being inserted into a text box
using a control varible. Can that control variable
also be used in some sort of calling syntax to
call the AfterUpdate event procedure that
corresponds to whatever text box is involved?

Not really -- you have to check the name of the variable and select from
among a hard-coded list of functions. Like this:

Select Case tbcntl.Name
Case "TextBox1": Call TextBox1_AfterUpdate()
Case "TextBox2": Call TextBox2_AfterUpdate()
' ... etc.
End Select
 
Dirk,
I was about to code it up that way when I decided
to check with the experts first...... oh well, but I thank
you anyway.
Bill
 
Back
Top