Updating values in combo boxes

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
 
A

Al Camp

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.
 
G

Guest

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
 
D

Daniel Doyle

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top