Updating values in combo boxes

Discussion in 'Microsoft Access Form Coding' started by Guest, Sep 7, 2005.

  1. Guest

    Guest 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
     
    Guest, Sep 7, 2005
    #1
    1. Advertisements

  2. Guest

    Al Camp Guest

    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


    "David Cleave" <> wrote in message
    news:...
    > 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
     
    Al Camp, Sep 7, 2005
    #2
    1. Advertisements

  3. Guest

    Guest Guest

    Good thinking!

    Thanks Al!

    "Al Camp" wrote:

    > 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
    >
    >
    > "David Cleave" <> wrote in message
    > news:...
    > > 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

    >
    >
    >
     
    Guest, Sep 7, 2005
    #3
  4. Guest

    Daniel Doyle Guest

    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

    "David Cleave" <> wrote in message
    news:...
    > 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
     
    Daniel Doyle, Sep 7, 2005
    #4
    1. Advertisements

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Guest

    Multiple combo boxes or list boxes

    Guest, Jun 2, 2004, in forum: Microsoft Access Form Coding
    Replies:
    10
    Views:
    279
    Guest
    Jun 3, 2004
  2. Ashley

    Change check boxes to combo boxes

    Ashley, Oct 1, 2004, in forum: Microsoft Access Form Coding
    Replies:
    1
    Views:
    207
    Jeff Boyce
    Oct 2, 2004
  3. Guest

    using text boxes and combo boxes together

    Guest, Sep 20, 2005, in forum: Microsoft Access Form Coding
    Replies:
    5
    Views:
    184
    Guest
    Sep 21, 2005
  4. Guest

    Basing combo boxes on 5 successive boxes

    Guest, Feb 8, 2007, in forum: Microsoft Access Form Coding
    Replies:
    2
    Views:
    897
    Guest
    Feb 9, 2007
  5. Fletcher

    Look up last entry for text boxes or combo boxes

    Fletcher, Jul 17, 2007, in forum: Microsoft Access Form Coding
    Replies:
    1
    Views:
    175
    Steve
    Jul 17, 2007
Loading...

Share This Page