Solved

Module Types

Posted on 2011-02-17
18
818 Views
Last Modified: 2013-11-28
Class Modules are used to create and define custom objects.
Form/ report modules contain the code behind forms/ reports.
But what are the modules that contain my subroutines and functions called?
0
Comment
Question by:Milewskp
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
18 Comments
 
LVL 17

Accepted Solution

by:
Barry Cunney earned 250 total points
ID: 34920414
I think they are called Standard Modules
http://www.tek-tips.com/faqs.cfm?fid=5319
0
 
LVL 28

Expert Comment

by:omgang
ID: 34920426
Standard module
OM Gang
0
 
LVL 75

Assisted Solution

by:DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) earned 250 total points
ID: 34920513
"Form/ report modules contain the code behind forms/ reports."
In fact, Form and Report *are* Class Modules also, except they are contained within the Form and Report object.

""But what are the modules that contain my subroutines and functions called?"
Standard VBA Modules.

mx
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 75
ID: 34920525
typo:

"In fact, Form and Report *are* Class Modules also"

>> In fact, Form and Report modules *are* Class Modules also.

mx
0
 
LVL 1

Author Comment

by:Milewskp
ID: 34920669
Hi mx,
<Form and Report modules *are* Class Modules >
Doesn't this imply that Forms and Reports are Classes?
The way I read BCUNNEY's link, Forms, Reports and Classes are all objects, but a form is not a report is not a class - they are distinct.
0
 
LVL 75
ID: 34920781
"Doesn't this imply that Forms and Reports are Classes?"
No. Forms & Reports are Objects.

The code modules contained within are Class Modules.  100% Guaranteed.

Have you ever noticed that you can create custom Form/Report properties *just* like you can in external Class Modules?  I do it all the time.  The only difference between the two is that external Class modules have Initialize and Terminate events.  Form and Reports ... Open/OnLoad ... Unload/Close.

That's how it is.

mx
0
 
LVL 75
ID: 34920999
You can see right in the VBA Object Browser (see image 1).

When you do this in code:

Dim frm As Form
Set frm = Form_frmMain
You have just set an object variable (frm) to Form Main's Class module

Note the custom Properties in image 2/3 for one of my Forms ...

mx
Capture1.gif
Capture2.gif
Capture3.gif
0
 
LVL 1

Author Comment

by:Milewskp
ID: 34922397
Hi mx,
<Form and Report modules *are* Class Modules >
If Form and Report Modules are Class Modules, then when you say 'Class module', you could be taking about a Form Module, a Report Module or a Class module that is not associated with a form or report.
So, when you are talking about this third type of module with your friends, what do you call it to distinguish it from Report Modules and Form Modules ('Class module that is not associated with a form or report' is as cumbersome as 'The artist formerly known as Prince'.)
0
 
LVL 75

Assisted Solution

by:DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) earned 250 total points
ID: 34922458
"So, when you are talking about this third type of module with your friends"
What 3rd type ?

In reality, there are only two types:
Regular VBA Modules
Class Modules
However, it's 'convenient' ... when code in a Form or Report is being discussed ... to say the Form module or Report Module. But that does not change the fact those modules are Class modules.

Remember ... A Form /  Report can have No module ... by setting the Has Module property to No.
When the property is set to Yes ... then what you have is a Class module 'behind' the Form/Report object.

mx
0
 
LVL 1

Author Comment

by:Milewskp
ID: 34922959
Hi mx,
<<"Doesn't this imply that Forms and Reports are Classes?">  No. Forms & Reports are Objects.>>
If you don't think that Forms and Reports are classes, I don't understand why you would want to call their modules 'Class Modules'. But of course, what you call them is your business.

Regardless, what you call a 'Class Module', BCUNNEY's link (http://www.tek-tips.com/faqs.cfm?fid=5319 )  calls an 'Object Module'. To confuse matters further, the VBA Project Explorer window lists Form and Report modules as 'Class Objects', and 'external' class modules as 'Class Modules'.

I prefer the term Object Module, since these modules describe objects, and because I can then use two words ('Class Module') instead of three (External Class Module) to describe what Microsoft calls 'Class Module'. But unless one term is much more commonly used than the other, I'd say it boils down to personal preference.

However, even if you accept the latter definition of Class module, it is not a very helpful definition, because whenever you use it you could be talking about a Form Class Module, a Report Class Module or an External Class Module.
From what I've googled, a Class is a custom object (or a template used to create custom objects), and a VBA code module that defines the properties, methods and events of a Class is called a Class Module.

Since a form is also a custom object and the VBA code module behind a form defines at least  some of its properties, methods and events, I agree that it is a Class Module.




A form, and the VBA code module that contains the code behind it, seems to me to have nothing to do with a Class. So it seems illogical to me to use the adjective 'Class' to describe such a module. On teh other hand, since it is the module behind a form, the obviuos name for such a module would be Form Module.
0
 
LVL 75
ID: 34923014
"A form, and the VBA code module that contains the code behind it, seems to me to have nothing to do with a Class."
It Does!  A Form or Report Module is a Class Module. Period. That's how it is.
mx
0
 
LVL 75

Assisted Solution

by:DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) earned 250 total points
ID: 34923083
From Help:

Type property as it applies to the Module object.

Indicates whether a module is a standard module or a class module. Read-only AcModuleType.

AcModuleType can be one of these AcModuleType constants.
acClassModule            1
acStandardModule      0

Then run this code inside of a Form or Report:

Private Sub Form_Load()

    Dim x, y, z
     x = acClassModule
     y = acStandardModule
     z = Me.Module.Type
     Debug.Print x & " " & y & " "; z
   
End Sub

This is the result:

1 0  1  (x,y,z)

They Type = 1 (one) = Class

As I said, the are only two types of Modules:
Standard VBA
Class

Any questions?

mx

0
 
LVL 75
ID: 34923102
In fact, do

Debug.Print Me.Module.Type

inside of a external Class module and you will get 1 (one).

Note that Me works in a Class module and *only* a Class module, which is why it works in a Form or Report (class) module.

mx
0
 
LVL 1

Author Comment

by:Milewskp
ID: 34925664
Hi all,
If my last post sounds like incoherent rambling, its because the last half was a draft that should have been deleted. The post should have been this:

<Hi mx,
<<"Doesn't this imply that Forms and Reports are Classes?">  No. Forms & Reports are Objects.>>
If you don't think that Forms and Reports are classes, I don't understand why you would want to call their modules 'Class Modules'. But of course, what you call them is your business.

Regardless, what you call a 'Class Module', BCUNNEY's link (http://www.tek-tips.com/faqs.cfm?fid=5319 )  calls an 'Object Module'. To confuse matters further, the VBA Project Explorer window lists Form and Report modules as 'Class Objects', and 'external' class modules as 'Class Modules'.

I prefer the term Object Module, since these modules describe objects, and because I can then use two words ('Class Module') instead of three (External Class Module) to describe what Microsoft calls 'Class Module'. But unless one term is much more commonly used than the other, I'd say it boils down to personal preference.>

0
 
LVL 1

Author Comment

by:Milewskp
ID: 34925669
Hi mx,
Thanks for that.
0
 
LVL 75
ID: 34927894
Milewskp:
With all due respect ... and this is not about points, this question has been answered.  If you want to disagree with Microsoft Help on the subject, that's fine. But ... it does not change the facts, nor does some random blog on the net by some totally unknown author ... who has a certain take on the subject.

That article does *not* change that fact - no matter how is is spun - that Form and Report modules are Class modules. Period.  The code snippet I posted proves this beyond any reasonable doubt.  There are only two kinds of modules. Period.  Just how and where the keyword Me is used ... alone demonstrates this.

There is no problem using the term Form and/or Report Module ... as long as you understand the Form and Report modules are Class modules.  There is no 3rd type.

mx

0
 
LVL 1

Author Comment

by:Milewskp
ID: 34952103
All,
Thanks for your help.

mx,
Thanks also for your patience. I think I get it now.


I will split the points.
0
 
LVL 75
ID: 34953545
No problem.

thx.mx
0

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

615 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question