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 19th, 2007, 10:32 AM
Registered User
Join Date: Jun 2007
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default Module Creation Problem

I have a project that has a number of Subs in it and I thought it would be easy to move some of the subs to modules. After moving the Public/Private subs to module(s), I get the dreaded "variable is undefined" error.

The variable that I'm having a problem with is declared in the first/main form of the project as a global variable (public) and as long as all of the subs are in the secondary form, there isn't a problem.

However, when I move the subs to modules, the compiler then reports that the globally defined variable is then undefined. What am I doing wrong?

Thanks in advance,


Old June 19th, 2007, 11:20 AM
Friend of Wrox
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts

Move the Public variables to a module. Create a module called Pblic, or something like that, and then do this:

Public vOne As String
Public vTwo As Integer

Clear them out from the forms. If they are in forms, they can only be initially called when the form is open. They can only be one place in the database, and a module is always available.

Hope that helps.

Old June 19th, 2007, 12:18 PM
Registered User
Join Date: Jun 2007
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts

Thank you! That did it.

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with Configuration Module Amateur BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 7 November 29th, 2006 12:26 PM
Module News Problem thanhh83 BOOK: ASP.NET Website Programming Problem-Design-Solution 9 May 16th, 2006 09:41 PM
problem with forum module anass BOOK: ASP.NET Website Programming Problem-Design-Solution 2 August 8th, 2005 01:47 AM
FileManager Module - Problem w/ Editor? Nothins2Sure BOOK: ASP.NET Website Programming Problem-Design-Solution 5 September 20th, 2004 09:39 PM
Problem understanding Object creation cdplayer Classic ASP Basics 4 March 18th, 2004 07:04 PM

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