DWUTKA at marlow.com
DWUTKA at marlow.com
Mon May 16 15:09:27 CDT 2005
That's a misnomer. An unhandled error is not unrelated. It only seems that way in Access, because it's running in an interpretted environment. Take a VB .exe, and the program stops with an unhandled error. Everything stops. In an interpretted environment, stopping the execution of code doesn't close Access, or the current database, it only stops the running code. This does not affect only Global Variables, it stops everything that is running. Sure, you may get another error later on, resulting from a Global Variable no longer having a value....however, you can also have a partially failed process already. Let's say you have 5 recordset processes that must be completed once they are started. If the 4th one fails, on an unhandled error, which is worse...the fact that 4 and 5 didn't complete, or that your global variables lost whatever values they were holding? Eh? Either way, the problem is not handling the errors, not that globals 'lose their values'.... Drew -----Original Message----- From: Dan Waters [mailto:dwaters at usinternet.com] Sent: Monday, May 16, 2005 1:46 PM To: 'Access Developers discussion and problem solving' Subject: RE: [AccessD] Global Variable And that's the reason Global variables can cause trouble - they get hammered by something completely unrelated! I've been putting my 'Global' variables into a hidden form (in a referenced .mde). When the app first opens, the variables are loaded into this form in unbound fields, and are then available by any other code. The variables contain values stored in the BE, but needed frequently by the FE - saves bandwidth. If there is an untrapped error, I don't lose the values. Dan Waters -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of MartyConnelly Sent: Monday, May 16, 2005 12:20 PM To: Access Developers discussion and problem solving Subject: Re: [AccessD] Global Variable Be aware of the fact that global variables lose their values after untrapped runtime errors. In a runtime Access environment this is no problem (Access crashes... and has to be restarted) In a full Access environment I have seen unpredictable result swith this. You may want to get at them from a lookup table or set in a class. Gustav Brock wrote: >Hi John > >You may like or prefer or need, or not, a global variable - that's up >to everyone to decide for him/herself - but they are not "bad practice", >not even in general. You may write clumsy code using globals, but not >using them gives no guarantee for nice code. > >/gustav > > > >>>>jwcolby at colbyconsulting.com 05/16 5:00 pm >>> >>>> >>>> >To dimension a global variable just go to the header of any module and >type >in > >Global MyVar as SomeVarType > >That's all there is to it, you can now reference the variable from any >code >in the project. Don't get carried away with them, they are considered >bad >practice in general. > >John W. Colby >www.ColbyConsulting.com > >Contribute your unused CPU cycles to a good cause: >http://folding.stanford.edu/ > >-----Original Message----- >From: accessd-bounces at databaseadvisors.com >[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Joe Rojas >Sent: Monday, May 16, 2005 10:54 AM >To: 'Access Developers discussion and problem solving' >Subject: [AccessD] Global Variable > > >Hi All, > >I am using a code example, from Microsoft, that allows me to print a >constant number of lines on a report. The code example uses a variable >that >is defined as Global. "Global TotCount As Integer" > >What's the deal with Global? I can't find it defined anywhere. > >TIA! >JR > > > -- Marty Connelly Victoria, B.C. Canada -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com