I have many TextBoxes in my form (about 14 TextBox)
I want all of them to behave in the same manner in the "BeforeUpdate"
event.
Is there any method to unify the code of the Event procedure, rather
than repeating it for every TextBox I have?
I know this is possible through class modules, but how?
Thanks
John Welch - 08 Dec 2005 18:23 GMT
Create a sub in the form's module (same place as the event code) and call it
whatever you want:
Private Sub DoStuffForTextBoxes
... put the code you want run here
End Sub
then in the before update event just say:
DoStuffForTextBoxes
and it will call your procedure.
If you need to send a value to the procedure, you can do that as well:
Check out the help on passing an argument to a function or subroutine.
>I have many TextBoxes in my form (about 14 TextBox)
> I want all of them to behave in the same manner in the "BeforeUpdate"
[quoted text clipped - 3 lines]
> I know this is possible through class modules, but how?
> Thanks
Marshall Barton - 08 Dec 2005 23:09 GMT
>I have many TextBoxes in my form (about 14 TextBox)
>I want all of them to behave in the same manner in the "BeforeUpdate"
>event.
>Is there any method to unify the code of the Event procedure, rather
>than repeating it for every TextBox I have?
>I know this is possible through class modules, but how?
You don't actually need a BeforeUpdate procedure for each
text box. Instead you can call your function by using
=Functionname()
in each of the text box's Before Update **property**
If the function needs to "know" which text boxes the
function is operating on, it can refer to it by using:
Me.ActiveControl

Signature
Marsh
MVP [MS Access]