.oldValue only shows current value

Copper Contributor

hi there

I have a small issue in Access that's driving me mad, so asking for some help please.

I have a form that has a few data input fields. For some data entry textboxes, I have an .BeforeUpdate event which should prompt the user to confirm changes were intended, only in case there was a previous value entered in the field. So if the field started empty, it won't prompt for confirmation. 


the sub starts with

If IsNull(me.ActiveControl.oldValue) Or me.ActiveControl.oldValue = 0 Then

Exit Sub

end if


Really simple code, but the issue I have is that the .oldvalue property always gives the same value as the current entered .value. So I cannot determine what was in the field before the user entered the new data.


The code event is triggered by the controlsource.beforeupdate event, so I am expecting this to be triggered before the record was changed.


frm.undo resets the form as expected to previous values , activecontrol.undo does not.


I cannot figure our what could cause this, and what work around I can think of. Any help appreciated!

2 Replies
you can "specifically" use the control name?

private sub Textbox1_BeforeUpdate(Cancel As Integer)
If Nz(Me.Textbox1, 0) = 0 Then
Exit Sub
End If
End Sub
hi, thanks- not sure I explained well. Basically, using your example:

private sub Textbox1_BeforeUpdate(Cancel As Integer)

Dim OldVal as Variant
Dim newVal as Variant

OldVal = me.textbox1.oldvalue
NewVal = me.textbox1

if NZ(OldVal,0) = 0 then
exit sub
end if
end sub

My issue is that however I call the control, as soon as I change the value in the textbox when triggering the _BeforeUpdate sub, OldVal property is already equal to NewVal. This is in the before saving, so the .OldValue should not have been updated yet.

I have my tables in the dataverse, I wonder if this is an error in Access due to that?