Wrox Programmer Forums
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 8th, 2006, 03:54 AM
Authorized User
 
Join Date: Dec 2005
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default include module function??

Hi all,

I am trying to manage my modules and was wondering if VBA has the
ability to import/include/require modules at runtime from outside the project.At the moment I have duplicate modules for each ACCESS
vba and everytime I need to change something I have to change ALL of it.... Other programming language can do this so there must be a way
to do this in VBA...I hope

I have tried using the code below but this seems to just add
module everytime I open the form

Code:
Private Sub Form_Open(Cancel As Integer)
    'Application.VBE.ActiveVBProject.VBComponents.Import (Application.CurrentProject.Path & "\test.bas")

End Sub
Please could someone help me on this issue.

Thank you
 
Old June 8th, 2006, 07:00 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Try deleting the existing module either before importing the new one, or import the new one, delete the old one, and rename the new one. Use

On Error Resume Next

(Import New Module)

If Err = 0 Then
   (Delete Old Module)
   (Rename New Module)
End If

Did that help?

mmcdonal
 
Old August 4th, 2006, 02:00 PM
pjm pjm is offline
Authorized User
 
Join Date: Jul 2006
Posts: 70
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I have the same issue myself. I've got quite a number of VBA functions/subs that I've written and I'd like to just include them with any new databases (instead of the constant copy & paste).

The way to do it (when I get the chance) is to put all the code in a .mda file and include a reference to it (Tools/References) in any new files.

-Phil-





Similar Threads
Thread Thread Starter Forum Replies Last Post
module umeshtheone VB Databases Basics 1 May 14th, 2007 01:41 PM
module? flora8 Access VBA 2 September 7th, 2006 11:10 AM
Module sohrabus ASP.NET 2.0 Professional 1 September 1st, 2006 12:26 AM
difference between include file & include virtual crmpicco Classic ASP Basics 2 January 23rd, 2006 11:50 AM
xsl:include within include chuck123ie XSLT 1 January 5th, 2006 11:07 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.