Solved Initialize More than One Class Module in a Form

Pac-Man

Active member
Local time
Today, 16:03
Joined
Apr 14, 2020
Messages
438
Hello,

I've two questions/confusions regarding class modules which I want to clear before I start working class modules for my forms. My form already have a class modules initialized. Now I want to add a code event on appx 80% of my textboxes on the forms plus same code will be applied to other forms' textboxes too so writing a class module would be time time saving instead of applying the piece of code on all the textboxes of all the forms so here are the confusions:

1. Can I initialize another class module in a form which already have a class module initialized?
2. If On Enter event of a textbox (say txtFName) has a code in it already and I initiate a class module which also have a piece of code in On Enter event of the textbox, what will happen now? I mean will both code run, or which one run?

I hope I could explain my queries well.

Best Regards
Abdullah
 
yes,
set cls1 = new class1
set cls2 = new class2
 
yes,
set cls1 = new class1
set cls2 = new class2
Thanks @Ranman256 for reply. So I get that two classes can be initiated and run in a single form without issue. What about two same events i.e. one in form while other in a class module for same control?
 
What about two same events i.e. one in form while other in a class module for same control?
You can trap an event in the Form's module and also in a custom class module/s at the same time.
 
You can trap an event in the Form's module and also in a custom class module/s at the same time.
Thanks a lot @MajP, can you please tell me which even will run first, forms module or class module?
 
See demo. Form's module trapped first.
 

Attachments

Users who are viewing this thread

Back
Top Bottom