Difference between module and all the VBA in the forms object

F

Frank Situmorang

Hello,

Can anyone help me why we still need a module if all VBA can be put in the
form or reports control source... In genereal what is the difference between
the module and all the VBA that already exsts in the forms and reports??

Thanks in adavance
 
J

John W. Vinson

Hello,

Can anyone help me why we still need a module if all VBA can be put in the
form or reports control source...

It can't. A Control Source applies to a control on a form or report (a Form
doesn't *have* a control source); the Recordsource of a form or report is not
VBA code but rather a SQL Query (or just a table, which is sort of a zeroth
order query).
In genereal what is the difference between
the module and all the VBA that already exsts in the forms and reports??

Thanks in adavance

The code in a Form or Report's events *IS* its module. You can have form
modules, and also standalone modules. They're all still modules.

John W. Vinson [MVP]
 
A

Albert D. Kallal

Frank Situmorang said:
Hello,

Can anyone help me why we still need a module if all VBA can be put in the
form or reports control source... In genereal what is the difference
between
the module and all the VBA that already exsts in the forms and reports??

One large difference is that code in standard modules can be used by ALL
forms, and the reverse is not true (in other words, code in one forms
module can't generally be used by other forms (or, if you actually do
attempt this, the form will have to be loaded, and opened).

if you look at a typical application of mine, I will have *MANY* code
modules. Here is a sample list from one of my applications....

api
60, lines of code. This is where general api code to "sleep" etc goes

basFtp
1320, this my custom ftp library code to upload, and download stuff from a
web site..

BookingStuff
1592, lines of code. There is where most of my general booking processing
code goes..."many" forms will share and use this code..and by using a
module, I don't have to repeat the code over and over in each form that uses
this code..

CGZipFiles - my custom routines to zip, and un-zip windows files

clsRidesPBar - my custom code for a progress bar...again, many forms might
need progress bar.

FileOpenApi - code to pop open the windows file dialog to select a file

locks - code for my custom locking code...

I have **many** more modules in this application, but as you can see, in
MOST
cases, the above code does NOT belong in a form, and furthermore it makes
it a
snap to share the code with other applications, or even additional forms....

So, code that you place in a standard module (as opposed to forms modules)
is the type of code that really don't belong in the form, but is code that
"many" forms and parts of the application may need...
 
F

Frank Situmorang

Thanks very much to all of you Albert for your explanation is a great help
to me, especially for us who live in the developping country. I do not know
how to express our thanks in English as our English knowledge also is very
limited. We can only say thanks a lot or we say it in Indonesia " Terimaksih
banyak"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top