Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using a parameter in generating an event name 1

Status
Not open for further replies.

VickyC

Technical User
Sep 25, 2010
206
CA
Greetings

I have a function that is used to reference 5 different text boxes (txtP, txtQ, txtR, txtS, txtT).

The function uses a 'dummy' argument, XX, to stand in for "P", "Q", ... "T" like this:

Function GetOutput(XX As String)
.....
If Len(Me.Controls("txt" & XX)) > 0 Then etc.....
.....

All of this works perfectly, but I now need to call the AfterUpdate event of the text box in question. I can't work out the syntax for this. For example, if XX = "Q", how do I get to XX to 'stand in' for Q in...

Call Me!txtQ_AfterUpdate

Thanks for any help
Vicky

(I currently cheat by just calling the AfterUpdate event of all 5 text boxes, but I'd like to know how to do this properly.)


 

do not call event procedures. Call some procedure and pass a parameter. My guess each of these event procedures do the same thing. Call a central procedure Also I would pass the control itself instead of a name.

My event procedures are almost always a single line of code. They call another procedure.




example
Private sub textA_afterUpdate()
call centralProcedure(me.textA)
end sub

Private sub textB_AfterUpdate()
call centralProcedure(me.TextB)
end sub

private sub CentralProcedure(txtBox as access.textBox)
txtBox.someProperty
with TxtBox
'if you do something slightly different for the textbox
select case txtBox.name
case "TxTBoxC"
some additional code for c
case "txtBoxD"
some additional code for d
end select
.
.
end with
end sub


Private sub Form_Current
could call the procedure from here
end sub

If you really wanted to call an event procedure add an intermediate procedure
so to fire the textA_afterupdate

call EventCall("TextA")

public sub EventCaller(strName as string)
select case strName
case "TextA"
call textA_AfterUpdate
......
end select
end sub
 
MajP - very insightful answer. Thank you
Vicky C.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top