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

abdullahkhan

Member
Local time
Today, 23:57
Joined
Apr 14, 2020
Messages
313
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, 13:57
Joined
Apr 9, 2015
Messages
3,958
yes,
set cls1 = new class1
set cls2 = new class2
 

abdullahkhan

Member
Local time
Today, 23:57
Joined
Apr 14, 2020
Messages
313
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, 13:57
Joined
May 21, 2018
Messages
5,686
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.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 13:57
Joined
May 21, 2018
Messages
5,686
See demo. Form's module trapped first.
 

Attachments

  • DemoEvents.accdb
    512 KB · Views: 217

Users who are viewing this thread

Top Bottom