Results 1 to 6 of 6

Thread: Modules? How?

  1. #1
    Join Date
    Nov 2003
    Posts
    104

    Unanswered: Modules? How?

    Hi All,
    I have a bit of code I use over and over again in multiple forms. I would like to stick this into a "module" of some sort so that more than one form can use it without me having to copy/paste the code in every form's code.

    How can this be done?

    NOTE: I am a dummy in VB/VBA.

    I am using Microsoft Access XP

    Thanx before hand

  2. #2
    Join Date
    Sep 2001
    Location
    Chicago, Illinois, USA
    Posts
    601
    Just stick it in a module.

    Just like you create a new form, you can create a new module.

    The only thing different from the code you are used to on the form is that the function/sub declaration in form code is automatically provided for you. In the module, you will need to provide that.

    So, to create a function in a module,

    just type Function NameOfYourFunction() as WhatEverDataTypeYouWant

    Then paste your code here, before the EndFunction statement.

  3. #3
    Join Date
    Nov 2003
    Posts
    104
    I see. now I see how to do it. But how do I "include" this module in various forms? Like how do I do something like #include ModuleName or import ModuleName?

    Thanx for bearing with me

  4. #4
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1
    You don't need to include this Functios like the # include statement.
    Any function or sub in a module can be called from any Form or Report

  5. #5
    Join Date
    Feb 2004
    Posts
    199
    "Any function or sub in a module can be called from any Form or Report" if the Function/Sub is declared as Public
    MDB, ADP <-> MS SQL + VBA, ADO & RDO, .NET, Oracle, Java/Jsp.

  6. #6
    Join Date
    Nov 2003
    Posts
    104
    Thanx for the feedback guys.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •