Question about retained values

  • Thread starter Thread starter C. Wilkins
  • Start date Start date
C

C. Wilkins

I have a form that I use (in new-entry mode) to enter
data into a table. The form is opened by a new-entry
button in a switchboard.

Is it possible to have the last (from the table) value
retained as a default, and have this update if/when
another entry has a different value? This would require
modifying the value and moving to the next record, in
which the last value in the table would be the new
default.

I'm specifically looking for where to look in help,
developer networks, or some code that can be modifed with
[form-field] and [table-field] adjustments. Thanks in
advance!
 
C. Wilkins said:
I have a form that I use (in new-entry mode) to enter
data into a table. The form is opened by a new-entry
button in a switchboard.

Is it possible to have the last (from the table) value
retained as a default, and have this update if/when
another entry has a different value? This would require
modifying the value and moving to the next record, in
which the last value in the table would be the new
default.

I'm specifically looking for where to look in help,
developer networks, or some code that can be modifed with
[form-field] and [table-field] adjustments.


There's a problem with your use of the word "last". Tables
have no built-in way of knowing what order records were
created. There are several other points that you should
clarify.

Do you have a monotonically increasing field (record
creation date/time?) in the table that can be used to
retrieve the value directly from the "latest" record. Note
that an AutoNumber field will NOT serve this purpose.

If not, then you'll have to save the value (when it's
entered) in another location (a special purpose table or a
custom created database property). How you do this depends
on if your database is single or multiple users. If
multiple users, is the databse split into a front end mdb
and a back end mdb?

All this also depends on what you want the new default value
to be. For example, if the new number is just the last
number plus one, you would do it differently than if it's a
name or some kind of arbitrary values.

Another question you should address is if this default value
only needs to be supplied while the form is open, or if it
must be retained from one session to the next. Doing it for
just the current session is very easy to do by adding a line
of code to the control's AfterUpdate event procedure:
thecontrol.DefaultValue = """" & thecontrol & """"
 
-----Original Message-----
There's a problem with your use of the word "last". Tables
have no built-in way of knowing what order records were
created. There are several other points that you should
clarify.

I was wondering about this. What I really wanted was the
value stored in a newly-created record, or the value last
entered in this position of the form.
Do you have a monotonically increasing field (record
creation date/time?) in the table that can be used to
retrieve the value directly from the "latest" record.
Note that an AutoNumber field will NOT serve this purpose.

Not monotonically increasing at all, and the only
individually identifying piece of data is the AutoNumber
and the location number (though that can be influenced by
deleting items, so it's unreliable. Creation date/time
isn't recorded at the moment, and I believe it would be
an unnecessary burden on the database and storage size to
include that.
If not, then you'll have to save the value (when it's
entered) in another location (a special purpose table or a
custom created database property). How you do this depends
on if your database is single or multiple users. If
multiple users, is the databse split into a front end mdb
and a back end mdb?

It's a single-user (at a time) database, so alterations
are all saved when another user accesses (pun intended)
the database.
All this also depends on what you want the new default value
to be. For example, if the new number is just the last
number plus one, you would do it differently than if it's a
name or some kind of arbitrary values.

Another question you should address is if this default value
only needs to be supplied while the form is open, or if it
must be retained from one session to the next. Doing it for
just the current session is very easy to do by adding a line
of code to the control's AfterUpdate event procedure:
thecontrol.DefaultValue = """" & thecontrol & """"

Thanks, everyone. I tested out both sections of code,
and I just wanted to retain the value that was previously
entered in that particular field of a data entry form
(similar to the CTRL-"apostraphe" function, without the
keystrokes). My question has been answered, though I had
to put the ([control].DefaultValue = """" & [control]
& """"") in a BeforeUpdate event procedure to get it to
update with the previous value without giving me an error.

Now this is in production, and saving time and company
money. <sarcasm> I just -love- updating other people's
work, especially when they used an auto-builder to make
the databases. </sarcasm> Thank you all, and I'll
continue to lurk in this newsgroup, keeping an eye out
for more solutions.

C. Wilkins
 
Back
Top