473,513 Members | 3,621 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Does custom form property get reset?

TD
I've read several posts here that say global variables are reset
whenever an unhandled error occurs. I want to use a custom form
property instead of a global variable to store a boolean value. My
question is does a custom form property get reset also? Was also
wondering if there is any reason one would ever use a global variable
since the consensus seems to be to never use global variables?

Feb 13 '06 #1
2 2286
How about a simple unbound check box on your form to hold the value while
the form is open, even if the variables are reset? (Make sure you set its
Default Value to False so it opens as unchecked.)

There are cases where global variables are needed to get around other
limitations. They can be helpful when you need to pass more information than
the built-in events allow. For example, you might OpenReport with a
WhereCondition, and you need the report to print an English description of
the way it is filtered. In Access 2000 and earlier versions, there was no
way to pass this extra argument to the report, so you need a global variable
that you assign the description to before you OpenReport, and then you can
read the global variable and assign it to the text box on the report in the
Format event the Report Header section. (Access 2002 and 2003 do have an
OpenArgs you can use to pass this info the report.)

But your thinking is essentially on track: use global variables only when
you are stuck, and only for short-term stuff. If it is possible to use a
local variable and pass it from procudure to procedure, that is the
perferred approach.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"TD" <dl**@adsi-sc.com> wrote in message
news:11*********************@g43g2000cwa.googlegro ups.com...
I've read several posts here that say global variables are reset
whenever an unhandled error occurs. I want to use a custom form
property instead of a global variable to store a boolean value. My
question is does a custom form property get reset also? Was also
wondering if there is any reason one would ever use a global variable
since the consensus seems to be to never use global variables?

Feb 13 '06 #2
"TD" <dl**@adsi-sc.com> wrote in message
news:11*********************@g43g2000cwa.googlegro ups.com...
I've read several posts here that say global variables are reset
whenever an unhandled error occurs. I want to use a custom form
property instead of a global variable to store a boolean value. My
question is does a custom form property get reset also? Was also
wondering if there is any reason one would ever use a global variable
since the consensus seems to be to never use global variables?


People use global variables because they are the easiest and quickest
(although not the most reliable) way to get the job done. They are easy
because you dimension them once and then can use them throughout the
application, and they are quick because they are held in memory and the
application does not need to read from or write to the disk in order to
retrieve and save them.

The big disadvantage is that, as you point out, they can get re-set with
un-handled errors. They are also open to being changed by any bit of code
in your application which you might have overlooked meaning that bugs can be
hard to track down.

So could you still use them? Well yes. Provided you are cautious about
their use, have ruled out other possibilities and ensure that use the
shortest possible span between setting them and retrieving the values.
Versions of Access prior to XP did not allow an OpenArgs argument to open
reports and so here you might set a global variable, open the report and let
the report's coding pick it the value of the variable. Provided you are
sensible about your coding, this is, in my opinion, reliable and acceptable.

So back to your question. Can the form's properties be reset? No, not
accidentally by unhandled errors but if your database is secured with
user-level security you may need to consider who can alter any custom
properties. You are also storing the setting with database whereas in some
circumstances it may be better to store the settings with the username in a
back-end table. So in a multi-user setting, a user could logon at any
machine and retrieve his/her settings.

In general, I would prefer to store app settings in a table and if I thought
that reading/writing would cause speed issues, then implement a way to load
them up at the start and save them back at the end.
Feb 15 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1424
by: Jordan Bowness | last post by:
I make a similar post in another newsgroup, but this example is simplified somewhat. I have a component (cmpMyComponent) with 2 properties. The 1st property is a string value (Description) and the 2nd property is a strongly typed collection class (myCollectionProperty). The collection contains a simple class (myCustomClass) which has 1...
2
2419
by: AMDRIT | last post by:
Hello everyone, I have created a custom component and one of its properties is a class object with it's own properties. During runtime, I can assign values to the class object properties just fine. However, when attempting to assing default values as designtime in the propertygrid, nothing is working on the class object. I know that I...
4
2324
by: Dries De Rudder | last post by:
Hi, I am trying to bind an object to form controls. I've got an object MyObject which has some properties e.g. ID. I've got a form, Form1, that contains a textbox ,TextBox1, now I want to bind the value of the ID-property of a MyObject-object to the TextBox1. I've tried doing this:
3
2839
by: Nina | last post by:
Hi there, I assigned icon for a window's form using form's Icon property at design time. Now I want to change the icon. I tried to replace the old icon with the new icon using form's Icon property. Somehow in the form's property window's Icon property has changed to new icon, but on the form it still uses the old icon. Then I tried...
1
6298
by: Stu | last post by:
Hi, Im using vis studio 2003 and I think wse is out of the question as clients could be using java which doesnt support it. So I managed to find some code which allows you to develop a custom soap header called by using a http module. The problem Im having is I cannot seem to get the event to raise to fire off my authenticate method in the...
19
4892
by: Jamey Shuemaker | last post by:
I'm in the process of expanding my knowledge and use of Class Modules. I've perused MSDN and this and other sites, and I'm pretty comfortable with my understanding of Class Modules with the exception of custom Collection Classes. Background: I'm developing an A2K .mdb to be deployed as an .mde at my current job-site. It has several custom...
0
1570
by: WhiteWizard | last post by:
I have built a custom control which sits on a panel. There is another panel on the form with a splitter between them. The custom control has a tab control on it, and I need to do two things: (1) When the control is loaded the FIRST tab seems to take it's scroll bar colors from the System (XP) rather than the control colors. The other tab...
6
2745
by: Erick | last post by:
I've created a class called Procs and a collection class called Processes which uses a hastable object to store the Procs. Now i want to enumerate with the "For each" to extract all the Procs in my Processes class. As far as i can tell i need to implement an IEnuerator method to do this. But how ? 'Procs Class Public Class Procs...
8
1621
by: Ethan Kennerly | last post by:
Hello, There are a lot of Python mailing lists. I hope this is an appropriate one for a question on properties. I am relatively inexperienced user of Python. I came to it to prototype concepts for videogames. Having programmed in C, scripted in Unix shells, and scripted in a number of proprietary game scripting languages, I'm...
0
7269
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7394
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7559
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7542
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5701
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5100
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4756
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3248
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
470
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.