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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Generic name for buttons.

Status
Not open for further replies.

paulbradley

Programmer
Oct 9, 2002
158
0
0
GB

I have A LOT of command buttons on one form. I want to write a function that changes the colour of the text box next to the button when it is pressed. I don't mind pasting a function call in for the 'on click' event for each button, but how do I write the function so it knows which text box to alter the colour of? Thanks!
 
pass the text box name as a parameter into the function

Function Change_Color(textbox)
.
.
.
End Function

So when you call it in the On Click event

Sub Command_Click
Call Change_Color(textboxname)

End Sub
 
Yup, that's a good way to do it. Another way is to refer to Screen.ActiveControl

Ken S.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top