What to do with a module?

  • Thread starter Thread starter Doug
  • Start date Start date
D

Doug

Friends,

As a amateur Access "developer", namely tables, queries,
forms, macros and reports, I have been given a module to
include within the database.

Any assistance given as to how/what to do next I will
send multitudenal blessings.

Thanks
 
I have been given a module to
include within the database.

A module is just a container with code.

If you have the module as , simply open the module pane, click right-click
on the module shortcut, click import, novigate to the module and .....

there you have it.

I think I understood your question
 
Doug,

In what format did this module come to you? As a text file? In an Access
database?

If the module is in an Access database, you can use File|Get External
Data|Import to import it into another database. If the module was given to
you in the form of a text file, first open the text file and then highlight
all of the text. Then click CTRL-C. Then open the Access database in which
you want to use this module. In the Database Window, click Modules, then
New. Your cursor will be positioned in the new module. Click CTRL-V; all
of the code copied from the text file will now be in the new module.

Click the Save button and give the Module a new name or accept the default
name and click OK.

Last, while the new module is still open, click Debug, then Compile. If
there are any errors in the code, each will be highlighted for you and you
will need to fix them (or contact the person who gave you the module).
Continue clicking Compile until the process completes without stopping at
any lines of code.
 
Thanks Frank,

Once I have the module within the db, how do I invoke the
code?

Thanks again.

Doug
 
The module will have Functions and Subs in it. They can be called from code using VBA from your forms.

For example, if I have a dozen forms that will all use the same error handler, I may put it in the module, this way any form can call it.

For example, if my error handler was declared as:
Public Sub ShowError ()
MsgBox "Error " & Err.Number & " occured."
End Sub

I could call it from a form using:

Sub Form_Load ()
On Error GoTo ErrorHandler:
<all my code>

ErrorHandler:
If Err.Number <> 0 then
ShowError 'Here is the call to the module
End If
End Sub
 
Doug,

You don't "run a module". A module is a collection of Visual Basic for
Applications declarations and procedures (functions and subs) that are
stored together as a unit.

Your original post indicated that you were "given a module". Did you
discuss the purpose of the module with the person who gave the module to
you? Have you opened the module in design view to determine what
declarations, functions and subs are found in it?
 
Back
Top