Solved Initialize More than One Class Module in a Form (1 Viewer)

Pac-Man

Active member
Local time
Today, 19:51
Joined
Apr 14, 2020
Messages
408
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
 

Ranman256

Well-known member
Local time
Today, 10:51
Joined
Apr 9, 2015
Messages
4,339
yes,
set cls1 = new class1
set cls2 = new class2
 

Pac-Man

Active member
Local time
Today, 19:51
Joined
Apr 14, 2020
Messages
408
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?
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 10:51
Joined
May 21, 2018
Messages
8,463
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.
 

Pac-Man

Active member
Local time
Today, 19:51
Joined
Apr 14, 2020
Messages
408
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?
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 10:51
Joined
May 21, 2018
Messages
8,463
See demo. Form's module trapped first.
 

Attachments

  • DemoEvents.accdb
    512 KB · Views: 581

Users who are viewing this thread

Top Bottom