Hey Gurus,
I know the topic is a little weird and I need your help badly.
I will explain the scenario first. I have been working on a project for my client in Access 2007. Now we have almost 25 windows with lots of textboxes in it. Now, when the whole project is almost ready, client has come back to us with a very strange requirement which is forcing us to include OnChange event, and a common code snippet in all of the textboxes.
I know I can write a function and go to each textbox and add the function one by one, but I just dont want to do it.
I thought of another way. I wrote the following example, and I am unsure how to implement it correctly so I need your help.
I wrote a class named Class1 with the following code:
Code:
Option Compare Database
Public WithEvents tb As TextBox
Private Sub tb_Change()
MsgBox "Changed"
End Sub
Then I have a form with a single textbox named Text0. I have the following code in the CodeBehind:
Code:
Option Compare DatabasePublic cls As Class1
Private Sub Form_Load()
Set cls = New Class1
Set cls.tb = Me.Text0 'binding the class's textbox with the form's textbox
End Sub
I am not a super programmer but I think when I have bound the class's textbox with my form's textbox, whenever I change the text in my form's textbox, it should call the on change event of class1 also. But it is not calling. I am really excited to know that on which part my logic stands failed and would really love if someone can explain me this issue in detail.
Thanks,
V
The sample db is attached here:
Database3.accdb