Updating values in combo boxes

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

Guest

Hi all

I’m having a serious problem with a combo box. I need it to tell me whenever
its value is changed. At the moment, I am testing its current value against
its .OldValue property. Problem is, the .OldValue property refers to the
value it held when the form was loaded, which gets out of date if the value
of the combo box is changed more than once.

Please tell me how I can either:
- force an update of the value of the combo box so that .OldValue property
contains the last value the combo box held
- access the last-held value of the combo box, if the .OldValue property
cannot be updated

Many thanks

David
 
David,
Not quite sure what you're doing here, but...
Use the OnCurrent event of the form to set a hidden text control or a
variable (ex. OldValue) to the combo value at OnCurrent time.
Use the BeforeUpdate event to "catch" changes, as compared to the
OldValue value. (perhaps warn the user?)
Use the AfterUpdate event to store a "new" OldValue if you allowed the
changes.
 
Good thinking!

Thanks Al!

Al Camp said:
David,
Not quite sure what you're doing here, but...
Use the OnCurrent event of the form to set a hidden text control or a
variable (ex. OldValue) to the combo value at OnCurrent time.
Use the BeforeUpdate event to "catch" changes, as compared to the
OldValue value. (perhaps warn the user?)
Use the AfterUpdate event to store a "new" OldValue if you allowed the
changes.
--
hth
Al Camp
Candia Computer Consulting - Candia NH
http://home.comcast.net/~cccsolutions
 
You could store the previous value in a form level variable and populate
this on the form's Current event and also the controls Enter event, although
Null may cause a problem.
Why do you need to capture the control's previous value - maybe there is a
better way to solve your problem?

Dan.

Option Compare Database
Option Explicit

Dim LastValue As String

Private Sub Form_Current()
LastValue = Me.Text0
End Sub

Private Sub Text0_Enter()
LastValue = Me.Text0
End Sub
 
Back
Top