Why is combo showing wrong value ?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sierra7
    Recognized Expert Contributor
    • Sep 2007
    • 446

    Why is combo showing wrong value ?

    Hi all
    I have a situation where I have an existing form that has funcioned well for years but is giving a problem running in Access 2010. There are two combo boxes in the header of a form, which set a filter criteria for displaying a stock listing.

    The combos 'cascade' such that the AfterUpdate event of combo1 sets a parameter and then a Requery of combo2.

    The AfterUpdate of combo2 sets the string for filtering the form and then calls Me.FilterOn = True. The data in the Detail section of the form is always correct (i.e. the filtering works ok) but the value displayed in combo2 can be wrong.

    If the form has just been opened then combo2 becomes blank after making a selection. If subsequent selections are made in combo2 it displays the correrct data.

    However, if combo1 is reselected (changed) and a new selection made from combo2, again the data is filtered correctly but the value displayed in combo2 is the previous value. It is only correct after making subsequent selections without changing combo1.

    The query returns four columns; the first is bound and the other three are zero width. The data is 'Limit to List' and yet the 'wrong' values are not in the list.

    I've followed my code in debug mode and fairly certain the process is as described above.

    Has anyone a clue to what is happening ?

    S7
  • nico5038
    Recognized Expert Specialist
    • Nov 2006
    • 3080

    #2
    Can you attach a sample database with this erroneous behavior, then I'll have a look tomorrow.

    Nic;o)

    Comment

    • sierra7
      Recognized Expert Contributor
      • Sep 2007
      • 446

      #3
      Originally posted by nico5038
      Can you attach a sample database with this erroneous behavior, then I'll have a look tomorrow.

      Nic;o)
      Yes, I was persuading myself to do this as my next step anyway. It's my first task this morning.

      Comment

      • sierra7
        Recognized Expert Contributor
        • Sep 2007
        • 446

        #4
        Originally posted by nico5038
        Can you attach a sample database with this erroneous behavior, then I'll have a look tomorrow.

        Nic;o)
        Problem solved!

        It seems that the 'Me.FilterOn = True' statement is causing an On_Got_Focus event to fire for the form in Access 2010 but not in 2003.

        I'm pretty certain about this because I have re-tested in both situations and inserted a MessageBox to announce 'Got Focus'.

        I had some 'residual' code in my original form which was trying to do things like 'DoCmd.Maximize ' and 'Me.Requery'. This was having no effect in 2003 but was causing my combo to roll back to a previous value in 2010. (At least I think that's what was going on!)

        I remember that when this system was being developed I had trouble resizing when moving between forms, and attempted to use 'Got Focus' and 'Activate' to trigger a re-size, with mixed results. I guess this code is a hang-over from then.

        It seems 2010 is a bit more rigorous that 2003 so it will be interesting what else reveals itself.

        Thanks for your help Nic;o) . Let me know if you still want the database to test this yourself and I'll try and work out how to attach it.

        Thanks
        S7

        Comment

        • nico5038
          Recognized Expert Specialist
          • Nov 2006
          • 3080

          #5
          It's sufficient to know that it's the event sequence causing the trouble. Have been running into a similar problem with an A2003 mdb that was upgraded to A2007.

          Success !

          Nic;o)

          Comment

          Working...