Solved Alternate way than global variables

PaquettePaul

Member
Local time
Today, 15:30
Joined
Mar 28, 2022
Messages
107
I have been using global variables and they worked in the spring but for some reason they are not working now. During my last visits here, people were talking about a different approach to declaring global variables but I can no longer remember what they were called. Please provide. Thanks
 
Perhaps TempVars.

Why would the globals no longer work - what changed?
 
There have been no changes to Access that would have "broken" global variables, so that change must represent some structural difference. The ways folks USUALLY accomplish data sharing across forms and/or reports is

a) global variables in a general module or a user-defined class - very large numbers of variables possible, no constraint on data type except possible size limits for the module as a whole.

b) a hidden form with unbound text-box controls - large number of variables but might be constrained as to number and type of values; cannot do the same thing with a report, though.

c) TempVars - up to 255 variables, each of which is named but must be a numeric type or text; cannot be objects or data structures

d) A named dictionary object - can store any object except an array

e) open a single-record recordset to be used for temp storage - up to 255 variables, cannot be objects or arrays, total characters in a record is constrained to 4K bytes, may have sharing constraints if multiple writers

There might be other ways to do this, but the above should cover most of the common ways.
 
Btw, thanks for the responses.

I use global variables to:
- set up configuration fields that are loaded at app startup (e.g., federal tax rate)
- define generic varIables that have limited life and I do not want to define in each procedure such as gblErr, gblInt, gblTxt, gblKey
- sometimes to make limited key data available from a form to a report

i had my problem because I restarted a global variable setup procedure in a secondary form for test purpos3s and forgot to remove it. I have no idea why I seem to find the solution shortly after reporting it as a problem in the forum. Maybe something about writing it down and thinking about how others might pose questions as to the characteristics of the problem and solutions.

Pat, when I first started using Access, I used a hidden form. I then found out about global variables and have stuck with them since.
 
Btw, thanks for the responses.

I use global variables to:
- set up configuration fields that are loaded at app startup (e.g., federal tax rate)
- define generic varIables that have limited life and I do not want to define in each procedure such as gblErr, gblInt, gblTxt, gblKey
- sometimes to make limited key data available from a form to a report

i had my problem because I restarted a global variable setup procedure in a secondary form for test purpos3s and forgot to remove it. I have no idea why I seem to find the solution shortly after reporting it as a problem in the forum. Maybe something about writing it down and thinking about how others might pose questions as to the characteristics of the problem and solutions.

Pat, when I first started using Access, I used a hidden form. I then found out about global variables and have stuck with them since.
I expect thinking about it again did jog your memory.
fwiw, Tempvars weren't a think when I started, and I have never got in the habit of using them. In some ways, I appreciate losing the value of some variables because of an unhandled error, because if I used Tempvars, I might not even appreciate that I had an error at all.

Maybe you could add a "sentinel" variable to indicate that the public variables have been set, so you exit the sub if you try to call it a second time.
 

Users who are viewing this thread

Back
Top Bottom