Forum Discussion
TheJaks
Mar 31, 2023Copper Contributor
.oldValue only shows current value
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...
arnel_gp
Steel Contributor
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
private sub Textbox1_BeforeUpdate(Cancel As Integer)
If Nz(Me.Textbox1, 0) = 0 Then
Exit Sub
End If
End Sub
TheJaks
Apr 06, 2023Copper Contributor
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?
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?