473,394 Members | 1,956 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes and contribute your articles to a community of 473,394 developers and data experts.

Why Values in Unbound Form Controls Don't Persist

NeoPa
32,556 Expert Mod 16PB
Introduction:
We get fairly frequent questions on here about why settings (including both values AND formatting) of unbound controls on a form, are not stored for reference later, but instead, each setting seems to be applied to EVERY instance of the control, for all records that show.

I will try to lay down all the reasoning and arguments that occur to me. Sometimes, it's harder to explain things when they appear to be self-evident. To me, this is entirely logical behaviour, so please feel free to say if this doesn't make understanding the situation any easier.

Reasoning:
Firstly, we should consider that a form, in Access, is a view of underlying recordset data. It is conceptually like a window. It can have pretty things stuck on around the side, but ultimately, it is a way of viewing data in an underlying (bound) recordset. It can also be used just to show the pretty things (unbound controls, unrelated to the underlying recordset), but we're not interested in that side of things for now.

Although the form can show various records, it doesn't itself, at any stage, store any of the values. Apart from the underlying recordset, nor does it make any arrangements to remember any settings for any of its controls. Although it appears to have a whole set of instances of itself (in continuous forms or datasheet modes), it only ever has as many instances as can be shown at any one time on the screen. All these instances are exact copies. Change any setting (including the value) and this will effect each and every one of them.

Points to Ponder:
For a control to maintain and persist associated data (as opposed to letting the data be managed by the underlying recordset), the whole concept would have to be fundamentally reorganised. More resources would be required (either a temp table just for this transient task or dynamically assigned RAM). Although maintaing such resources for a data set, for which originally at least, the limits may yet be unknown, is possible, it is not a trivial thing and would certainly introduce complication into a situation which doesn't really require it. I can't resist adding here that, with MS's reputation for losing track of resources and not closing stuff down properly - would this be a good move?

As I mentioned earlier though, the form is like a window that allows both viewing and access (manipulation) of a small subset of the recordset at a time. Extending the concept to handle a full recordset, without linking that to the recordset itself (using Bound controls in other words) would not even be desirable. It would actually fit the logic less well and be some sort of hybrid that made PROPER sense to no-one.

Update:
Interestingly, though the previous part of the article can remain in place and still be considered to be true, there is a loophole that may prove interesting to many who desire to show different formatting and display properties of a control (and its value) for each record individually. Fascinating, I hear you say (Echoing my own thoughts when the concept was introduced to me by Stewart Ross in the thread Conditional Formatting Access 2007 - Reports).

NB. Because of how this works, it only makes sense that it can work for a Report object, but not for a Form. Once a control design is changed it is refreshed for all instances on a Form, but this is not how a Report works. Read on to understand why.

Fundamentally, taking the concept of an old-style film camera, one can update the control just before the image is painted onto the Report (Using the Format event procedure, usually of the Detail section). As it is only changed (and always changed) immediately prior to formatting, the formatted output always reflects the results of the conditions pertaining to each individual record.

Here's an example that illustrates the flexibility :
Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2. Option Explicit
  3.  
  4. Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
  5.     With Me
  6.         .lblScore.BackColor = &HFFFF00 + 2 * .txtScore
  7.         .txtScore.BackColor = &HFF00FF + (&H100& * (&HFF& - 2 * .txtScore))
  8.     End With
  9. End Sub
The score ranges from 0 to 101 in the sample data and, to avoid a dull grey illustration, I left out one of the hues from the colours of each control. It displays like :

Attached Images
File Type: jpg CondFormatting.Jpg (7.2 KB, 2399 views)
Sep 22 '08 #1
0 12830

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

Similar topics

3
by: Dos Lil | last post by:
I have a unbound field in the subform(for calculating the datediff) which has the control property ==DateDiff("n",,). I have another unbound field in the main form which is for displaying the...
7
by: Javaman59 | last post by:
This is about finding the right point at which to save user entered data in the registry, so that when the application is restarted, the saved values will be restored. I want this behaviour to be...
1
by: Richard Dixson | last post by:
Under ASP.NET (C#) I want to create a page that people can use to submit questions. This page will consist of a table with several rows of information, like: Name: Bill Smith Job title:...
2
by: Richard Dixson | last post by:
Under ASP.NET (C#) I want to create a page that people can use to submit questions. This page will consist of a table with several rows of information, like: Name: Bill Smith Job title:...
8
by: Chris | last post by:
Hi, I have two froms (form1 and form2). I want to be able to pass values from form 1 to form2 and be able to use those values leter in form2. This is my code for form1 Private Sub...
1
by: planetthoughtful | last post by:
Hi All, I have a mainform with a subform in which I show some task summary data. On the mainform I have a number of unbound controls that reflect values relevant to each task in the subform....
8
by: Robert | last post by:
I have a form (Worksheet) that works fine by itself. I have now created a seperate form (MainForm) that has a command button in the header and an unbound subform (FormFrame) in the Detail section....
7
by: ARC | last post by:
I've noticed that if you use code for the before update command for unbound controls, it doesn't really work. I tried the following: Me!ExportedYN.undo Cancel = True DoCmd.CancelEvent Exit...
24
by: NaftoliGug | last post by:
Is there a way to have unbound, uncalculated controls (or a calculated control that is based on a function) that retains a different value for each record?
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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...

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.