I have a form with a number of text boxes. I want to write ONE sub that is called after each text box update that changes the box color. I basically need the syntax to find the current textbox name. Thanks!
The approach that the Access Menu wizard takes is for one subroutine that is called by each of the controls. The controls then pass their own name to the sub in the Call
Eg. To set the BackColour to RED as soon as a control is changed:-
Private Sub textBox1_AfterUpdate()
Call FormatTextBox(textBox1)
End Sub
Private Sub textBox2_AfterUpdate()
Call FormatTextBox(textBox2)
End Sub
Private Sub textBox3_AfterUpdate()
Call FormatTextBox(textBox3)
End Sub
Private Sub FormatTextBox(CallingObject As Control)
CallingObject.Properties("BackColor" = 255
EndSub
'ope-that-'elps.
G LS
accessaceNOJUNK@valleyalley.co.uk
Remove the NOJUNK to use.
Yes, that works, thanks. This is just about the same as coding the colorchange for each textbox. I thuoght there would be a far quicker way, something along the lines of:
if data in form is changed then
find textbox name
change color(text boxname)
End If
Yes seeff, thats true, but in the spirit of 're-usable code'
You can do a whole range of complete formatting this way and if you want to update it then there is only one place to make the change.
The problem with what you had in mind, I think, is that if you could find an event to run off, that occured every time a control was updated, then the event's own object ( the form ) would have the focus. If the form has the focus - then the individual control does not. Sorting out the code to work out which control did just have the focus would be far more conplex than the solution above.
G LS
accessaceNOJUNK@valleyalley.co.uk
Remove the NOJUNK to use.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.