Has the value in a control changed ?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I need to see if the value in a control has changed from the time that the
form opened until the time that the form is closed.

Here is my proposed code:

At the beginning of accessing the form ("frmTrxWInvoicesExp"), I store the
sum of the invoices into a variable in a module of Global Variables

************************************************************

Private Sub Form_Load()
modGlobalVariables.EarlySumInvExp = Nz(Me![2tblInvoices
Subform]!SumOfInvExp, 0)
'MsgBox "The value is " & Me![2tblInvoices Subform]!SumOfInvExp
End Sub

***************************
Then when I go to leave the form I access the some additional code. and look
at the difference between the values of the first sum (of invoices) and the
last sum (of invoices). If there is a difference, then I make changes, and if
not, then I carry on exiting the form.

*********************************
When I go thru the loop the first time round (ie thru an "open the form" and
"close the form") things seem to work as they should. However, the problem
that I encounter is that the 2nd time (as well as subsequent times) the form
no longer gets the value of Me![2tblInvoices Subform]!SumOfInvExp.

So the question is : Have I got the proper syntax for this sum? or is there
something else wrong with my approach to the problem?
 
Marty,

Search VBA help for "OldValue". It explains how to use and when it changes,
but I can't really tell you how it reacts to a calculated or unbound field.

If that doesn't do it, use Form_Current to store the initial calculated
value in a form level variable (one defined at the top of the form's code,
not in a particular sub or function), then test it against the current value
of the calculated field before exiting.

Bruce
 
Back
Top