473,405 Members | 2,210 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

OldValue not set

In Access 2003, I have a form (continuous form view) with several text
boxes. The text boxes are not bound to a table since the layout of the
form differs greatly from the structure of the normalized table into
which the data must go. Each time the text in any one box is modified,
I have code to carry out some appropriate action. E.g., if the textbox
is empty and a value is added, then a new record is created in the
normalized table. Also e.g., if the textbox has a value in it already
and the value is changed, then the matching record in the table is
found and updated. If a value is removed, then the matching record is
deleted.

To achieve this, I'm using each textbox's OldValue property. It works
quite well if you enter data into only one text box. But if you enter
in one box, then enter more data in another box, then go back to the
first box and remove the data, an Invalid Use of Null error is
given--the OldValue is Null even though there was a value in the box.
In the code below, when I remove a value from a textbox (which should
delete a record in the table), I get an error on the line "Call
f_AddRecord..." since OldValue is mysteriously set to Null and, of
course, the textbox's current value is Null too since I just removed
the value.

Here's the code for one of the text boxes:

Private Sub Ctl25d_AfterUpdate()
If Not IsNull(species_code_FD) Then
If IsNull(Ctl25d.OldValue) Then
Call f_AddRecord(Ctl25d.Value, Ctl25d.Tag)
ElseIf Not IsNull(Ctl25d.OldValue) Then
If Not IsNull(Ctl25d.Value) Then
Call f_UpdateRec(Ctl25d.Value, Ctl25d.Tag)
Else 'Ctl25d is null
Call f_RemoveRecord(Ctl25d.OldValue, Ctl25d.Tag)
End If
End If
End If 'species code null
End Sub

Any help is greatly appreciated!

Doug in Fairbanks

Dec 22 '05 #1
5 7623
Hmm. Not sure how it works when you deal with only one field, but the
OldValue property doesn't do anything for you if you're working with an
unbound form. There are a lot of ways to deal with this, including
tossing the original value into the tag of the control at the same time
as you load the value into it.

Jeremy

Dec 22 '05 #2
Yes, well, I must confess that the form actually *is* bound to a table
so as data are entered, they are stored there. But that table is not
the normalized table and is only a failsafe place to store the data if
for some reason the data are not written to the proper table (the
normalized one).

The .tag idea is a good one but I'm using the tag already to hold a
value used when the data are mapped into the normalized table. But I
could use something like the status bar text or controltip to hold the
info....

Dec 22 '05 #3
So I'm now using the StatusBarText to hold the old value and it's
working until you go to a new record and try to add a value in a text
box that was given a value in an earlier record. That is, the
StatusBarText is not reset to null when you go to a new record.

Why, oh why doesn't .OldValue work as you think it should!!!

Dec 22 '05 #4
On 22 Dec 2005 15:19:35 -0800, "Dugo" <Do*********@nps.gov> wrote:
Why, oh why doesn't .OldValue work as you think it should!!!


It may not work as you think it should, but it does work exactly as explained in the help files.
OldValue only works with BOUND controls because the OldValue is actually the current value of the control's bound field
as stored in the underlying table before the record is edited. If the control is unbound then there is no OldValue.

Why not use a form level variable to store the value of the control?

Sub SomeControl_Enter()

MyVariable = Me.SomeControl

End Sub

To undo it use -

Me.SomeControl = MyVariable
Wayne Gillespie
Gosford NSW Australia
Dec 22 '05 #5
You replied to my "why o why" statement just as secretly did to myself
(it's something in *my* thinking that's the problem). The form and
textboxes actually are bound to a table so I'm still not sure why
..OldValue isn't working as I hoped (again, it must be something with my
hope that's the problem).

I did try using a form level variable but abandoned it for some
reason...maybe I should revisit it. But I've got around the problem by
having the statusbartext set in the GotFocus event for each text box.
Not too elegant but it works.

All in all, if I didn't have to stick with a normalized table to store
the data, things would be much easier. And since this db won't be used
by more than 5 people at once and because the number of records won't
top 100k in any one table for years to come, it seems to me that
normalization is unneeded in this case. But we're grandfathered into it
so I must cope.

Thanks again,
Doug

Dec 23 '05 #6

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

Similar topics

1
by: Andi Plotsky | last post by:
I am running some code to validate the entry made into a form called NumberOfSamples. If validation fails, then I want to revert back to the old value. I keep getting an error msg that says: ...
0
by: Bob Darlington | last post by:
I'm using the following code, which is called from the BeforeUpdate event in a form based on 'Tenant Details', to check for changes or additions to a series of dates, and if changed, to edit...
1
by: Scott R | last post by:
I want to be able to see the changes a user makes while in the Edit Mode of FormView. My understanding is that in the FormView ItemUpdating event, I should be able to get a collection of Keys,...
1
by: gazelle04 | last post by:
I have these on BeforeUpdate event of a control If Me.txtAddress.Value <> Me.txtAddress.OldValue Then Me.txtGenInfo_UpdatedOn = Now Me.txtGenInfo_UpdatedBy = fOSUserName ...
2
by: Keith Wilby | last post by:
In A2k3 is it possible to determine if the OldValue property for a check box exists using code? Thanks. Keith.
1
by: David C | last post by:
Using ASP.Net 2.0 and VS2005. I have a GridView that is bound to an SqlDataSource and I want to get and hold the previous value of a bound control on the row I am editing. Below is what I am...
1
by: DaAdmin | last post by:
I am making a Cancel button to close a form without saving. I check for changes in each control and if it changed I want to restore it to the old value, I get an error saying I can't assign value to...
8
by: Avi | last post by:
Hi all, I'm using string Replace(string oldValue, string newValue) and would like it to replace only full words that matches oldValue and not when oldValue is a substring of a larger word. ...
1
by: Allen Browne | last post by:
Testing if the new value is different from the old one avoids giving the message in these cases: a) It's a new record (so there was no old value.) b) No customer was specified previously (so the...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...

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.