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!

Reference a control in a function

Status
Not open for further replies.

JimmyN

Programmer
Sep 2, 2000
26
0
0
GB
I have a form (MyForm) with many identical bound textboxes that all need the same OnDblClick event. I don't want to have code for each control but rather call a function. The function is very simple - enter a numeric value into the bound field and change the control's back colour. The function therefore needs to know the control that called it.

I think I need to do something like the following, but do not know the correct method:

Set the OnDblClick event for each control to, say "=funcDblClick()"

then have a function in a module something like:

Function funcDblClick()
[Forms]![MyForm]![Control that called function] = Value
[Forms]![MyForm]![Control that called function].BackColor = 255
End Function

How do I pass the control reference to the function?
 
Take a look at the ActiveControl property.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Thank you PH - problem solved.

JimmyN
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top