473,402 Members | 2,053 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

Public Variables Persistence

43
Hi,

I created some Public variables using Access 97 to hold often used database options.

One example is a variable to test for debugging mode, so the code can make special considerations for printing debugging code, etc.

The variables are set in the top of a module, before any Procedures with this kind of syntax:

Expand|Select|Wrap|Line Numbers
  1. Public bDBUGGING as Boolean 

In Access 97 it works fine. The value stays in the public variable in between actual testing runs, while I am coding, etc. Then when code is ran it finds the values previously set, either by hand or in VBA code.

When I try to use this in Access 2003 however, it acts different. It holds the value while the code is executing but then loses the value when execution finishes.

Is there any way in 2003 to configure the database to keep the value between code runs? For example, when you are just sitting at a menu, the VBA is not executing, and then you click a button that uses the this value.
Mar 15 '12 #1
2 1904
Sedrick
43
Thanks for looking.

I think I found the problem.

I had an error going on with some assignments to a Collection. For some reason it seemed to assign all the properties of a form to it instead of the string. When I cleared that up, the other problem with the public variables holding their values cleared up!

I also recalled that a Public variable will lose its value under some error conditions.

(By the way, the workaround to the collections assignment problem seemed to be related to variable types. When reading values from a table and assigning them or when trying to add a collection member of type Variant. I solved it with a work-around that explicitly converts the variable type before assigning the value to the collection.)

Thanks again!
Mar 15 '12 #2
NeoPa
32,556 Expert Mod 16PB
FYI: Any time your code is reset, which happens automatically after a crash unless the debug option is avaialable and chosen, all public variables are, of necessity, reset. All values are therefore lost at this point, clearly.
Mar 16 '12 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Jose Meireles | last post by:
Hi everyone, I'm trying to use public variables in a web form to hld specific values. What happens is that the public variables (declared as public x as y in the beginning of the class), doesn't...
3
by: Parintas Themis STE Kardias | last post by:
Hi How can i use public variables. These variables i wand to use in different places on a form (like a button) and are neccessery to write the type of variable like: Public VAR1, var2 as integer...
4
by: Darrel | last post by:
I'm really stuck on the concept of using public variables to pass information between usercontrols. I'm pretty sure I'm just flubbing up the syntax. This is what I want: page usercontrol 1 -...
6
by: darrel | last post by:
I'm still not quite sure how best to handle the passing of data between controls. This is a method I'm using at the moment: I have an XML file that contains a variety of page-centric...
2
by: vvenk | last post by:
Hello: I have defined public variables in Global.asax.vb that are initialized in the application_start event. How do I reference these variables in other ASP forms? For example, if my...
4
by: Webster | last post by:
Hello, Just wondering what's better programming style; to use public variables in a class or to use private/protected variables and then expose them via properties? For example:...
12
by: jimfortune | last post by:
I have a question based somewhat on: http://groups.google.com/group/comp.databases.ms-access/browse_frm/thread/ddde992b84f762bd/152bbc027bf00720?hl=en#152bbc027bf00720 A local table works well...
7
by: Steve Mauldin | last post by:
I have a public variable that is declared in a public module. This Variable is stored into a Session variable and used to pass data from page to page. I am seeing on my local development box that...
3
by: PhilippeM | last post by:
Hi everyone! I have defined 3 public variables: Public OldCompany As Variant Public OldLast As Variant Public OldFirst As Variant A procedure defines those variables: OldCompany = !Company...
2
by: JaketheSnake27 | last post by:
I'm trying to define a field in a query using an expression. Part of that expression involves using public variables. First of all, is it possible to use variables in a query field? And if it is,...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.