Before/After Values Test

collizz

Registered User.
Local time
Today, 16:30
Joined
Feb 6, 2006
Messages
29
Hopefully a simple one:

I'm trying to put together a simple before/after check on a continuous form's (frmActor) bound control (actorName), and then posting any changes to an audit table (tblModHistory).

When I make a change and hit either <TAB> or <ENTER>, the control values Me.actorName and Me.actorName.oldValue are set correctly and I can post these to the audit table.

However, when I make the change, and then click away from that row (either on another row or on a button that closes the form) I get either the same value in both or one of the values is retained from a previous row.

I have probably tried every combination of control event the correct one!

Where do I test the before and after values of the control to get the correct values, regardless of method of exit?

Thank you
 
might be helpful to see some code.
after the update, are you sure that Me.actorName.oldValue is looking up tblModHistory and not the current value?
 
you need to test this in the before update event for the individual field/control , i think

once you move to another control, i think the oldvalue will be gone
 
In a continuous form, moving to another "row" will save the record thereby making the .OldValue and .Value the same. Use the BeroreUpdate event of the Continuous Form to do your validation. That event will fire *every* time the form tries to save a dirty record regardless of how the user exits the record.
 
...once you move to another control, i think the oldvalue will be gone
Actually, it should still be there until you move to another RECORD. However, there are also certain circumstances where the .OldValue will not work. See here for one of those.
 
Thanks to all for the helpful replies. I managed to get it sorted by using the GotFocus and LostFocus events to store the values in public variables. Probably not the 'right' way to do it, but it worked for me.

I was so smug about solving that, I decided to be adventurous and split the db. That worked fine, but now I need to copy the database to another server (at work) and the path for the data (_be.accdb) is still set to my laptop home folder.

Any ideas how I can reset the paths for both data and code to my local drive at work? This is a 'one off' so there's no need to consider networks, etc. That will be handled later, once this is working.

Thanks again.
 
Actually, it should still be there until you move to another RECORD. However, there are also certain circumstances where the .OldValue will not work. See here for one of those.

Bob

I recollect having problems with control.oldvalue with a combo box - I have tried to compare (in the control's before update) event the old value, with the new value, and the old value always seems to be the same - even when i know its different.

Thinking about it, access must store all the old values until you leave the reocrd, as it can undo back to the original values.
 

Users who are viewing this thread

Back
Top Bottom