copy controls

  • Thread starter Thread starter Kurt Neumann
  • Start date Start date
K

Kurt Neumann

in constructing a form, I have many text boxes that i want to have the same
exit event procedure. Is there a way to copy one control with its event
procedures so that I can just paste it over and over onto the form in order
that I have many of the same type of unbounded textbox with the same exit
procedure?
thanks
khn
 
Kurt,

Just add the controls to the form as normal. Then write a form function to
handle the Exit event. Select all the controls that will execute this
procedure, and type the function name (including the trailing parentheses)
into the controls' On Exit property (on the Properties dialog):
=MyCustomExit()

If different actions will take place according to the specific control being
exited, just add the control's name as an argument:
=MyCustomExit("txtMyTextBox1")

.... and ...
Private Function MyCustomExit(strControlName As String)
Select Case strControlName
Case "txtMyTextBox1"
'Implementation omitted
Case "txtMyTextBox2"
'Implementation omitted
End Select
End Function

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia

Microsoft Access 2003 VBA Programmer's Reference
http://www.wiley.com/WileyCDA/WileyTitle/productCd-0764559036.html
 
thanks!
Graham R Seach said:
Kurt,

Just add the controls to the form as normal. Then write a form function to
handle the Exit event. Select all the controls that will execute this
procedure, and type the function name (including the trailing parentheses)
into the controls' On Exit property (on the Properties dialog):
=MyCustomExit()

If different actions will take place according to the specific control being
exited, just add the control's name as an argument:
=MyCustomExit("txtMyTextBox1")

... and ...
Private Function MyCustomExit(strControlName As String)
Select Case strControlName
Case "txtMyTextBox1"
'Implementation omitted
Case "txtMyTextBox2"
'Implementation omitted
End Select
End Function

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia

Microsoft Access 2003 VBA Programmer's Reference
http://www.wiley.com/WileyCDA/WileyTitle/productCd-0764559036.html
 
Back
Top