Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6339287
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T19:37:21+00:00 2026-05-24T19:37:21+00:00

I have a Access 2003 database that will dynamically load MDB databases as a

  • 0

I have a Access 2003 database that will dynamically load MDB databases as a library reference. The reason for this is this database is a menu front-end for 60+ application databases. Rather than deal with permanently referencing all these databases, the menu front-end will dynamically reference what is needed when the user makes a selection. I was working on moving this database to Access 2010 and creating a custom ribbon. I started using the technique from here to capture the ribbon object in a global variable when the ribbon loads. I then ran into the problem where I could verify the code was running and the global variable was correctly being assigned the ribbon reference but after the database would run through it’s startup routine, that global variable would get reset to Nothing.

To verify what was going on, I created a simple database for testing. In this database, I had a module with a global variable:

Public obj as Object

I then had a function like this:

Public Function SetObj()

Set obj = Application

Debug.Print "IsNothing=" & (obj Is Nothing)

References.AddFromFile "Test.mdb"

Debug.Print "IsNothing=" & (obj Is Nothing)

End Function

Obviously, in my code, “Test.mdb” refers to an actual file. If I run this code, Debug.Print gives me “IsNothing=False” for both instances, but after the function finishes and if I wait a couple seconds, Debug.Print will give me “IsNothing=True”. If I comment out References.AddFromFile, Debug.Print gives me “IsNothing=False” no matter how long I wait.

It makes sense to me that since Access has to re-compile the VBA code after loading the library that all global variables are reset. I’ve experimented with moving the global variable into a class, but since I then need a global variable for the class, the class variable then gets reset instead. I tried using a local variable in the function to save the value of the global variable, but it looks like Access waits a couple seconds after the code is finished running to do the re-compile, so that doesn’t work either. Does anyone have any other ideas to accomplish this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T19:37:23+00:00Added an answer on May 24, 2026 at 7:37 pm

    I don’t really know if this will solve the problem for this kind of reference, but in general, I don’t use public variables for this kind of thing, but instead use a STATIC variable inside your function. It would be something like this:

      Public Function SetObj() As Object
        Static obj As Object
    
        If (obj Is Nothing) Then
           Set obj = Application
        End If
        Set SetObj = obj
      End Function
    

    Then you’d just use SetObj as an object for using your application. In a production app, you’d need tear-down code, too, but I’ve omitted that here.

    I doubt this helps, but your code struck me as rather inefficient and incomplete.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a project that will be using Access 2003 as the front-end and
I am creating a database application using Access 2003 that will be run as
I have an Access 2003 database that connects to a SQL Server 2008 box
I have an Access 2003 database MDB where all of the tables exist as
I have an MS Access 2003 database that I'm using to develop a basic
I have an Ms-Access database (2003) and I have noticed that it gives OledbException:
So I have this Access Database Project file that I have been tasked to
I have an Access 2003 database using MS-JET linked tables (that is, there are
I have an Access 2003 database that makes use of a combobox that contains
I have a database in Access 2003 that I only want certain people to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.