Hi,
AFAIK, its not possible to have a dynaimic function, but you can do this
Private Sub gentxtbox(byref X as integer, tbox as textbox)
intLnumber = X
'.... the tbox is optional but it allows you to access the textbox directly
if tbox.vlaue="Hello, World" then msgbox "Hello!"
'or you can just use the number as in
if me.controls("txtbox" & X).vlaue="Hello, World" then msgbox "Hello!"
End Sub
Private Sub txtbox1_AfterUpdate()
gentxtbox(1, me.txtbox1)
end sub
Private Sub txtbox2_AfterUpdate()
gentxtbox(2, me.txtbox2)
end sub
'....
--
Hope this helps
Martin Fishlock, Bangkok, Thailand
Please do not forget to rate this reply.
"Richard" wrote:
Hello,
Hope some can help me here.
As you can see the example below, I want to write the Sub function only once
and able to run the sub function based which txtbox has been updated by a
user.
Assume X is the variable of the text box.
Can you help me to update "Private Sub txtbox"X"_AfterUpdate()" code, please?
Thank you for your help and time.
Example I have 10 text boxes, txtbox1, txtbox2, txtbox3,.....txtbox9, and
txtbox10.
Private Sub txtbox"X"_AfterUpdate()
intLnumber = X ' I want to run some coding here based which txtbox has
been updated.
End Sub