'Blip' when returning to listbox

  • Thread starter Thread starter David
  • Start date Start date
D

David

My screen containing a listbox is working fine apart from
one thing. When I return to it from another screen, there
is a 'blip'. It seems like the listbox is displayed and
then almost immediately refreshed. Any idea what could
cause this. There are some requery statements sprinkled
throughtout the code which trigger based on the setting of
various global variables the meaning and use of which
escape me. Could this be the cause?
I have code in the form Load event and the Activate event.
The SQL rowsource is built in the Activate event because
the selection criteria are at the top of the form and so
could change for each display.
 
David said:
My screen containing a listbox is working fine apart from
one thing. When I return to it from another screen, there
is a 'blip'. It seems like the listbox is displayed and
then almost immediately refreshed. Any idea what could
cause this. There are some requery statements sprinkled
throughtout the code which trigger based on the setting of
various global variables the meaning and use of which
escape me. Could this be the cause?

Quite possibly. Without seeing the code, it's impossible to tell.
I have code in the form Load event and the Activate event.
The SQL rowsource is built in the Activate event because
the selection criteria are at the top of the form and so
could change for each display.

So, somehow, every time the focus switches back to this form the
selection criteria may be different? That's kind of odd. Are these
criteria being changed from other forms? One possibility, if that is
the case, is to drop the requery from the Activate event and instead
call it only from those places where a criterion value is actually
changed.
 
Originally this form only had an ACTIVATE event handler. I
have no idea why. I transferred some logic into the LOAD
event. But the rowsource set up is still in the ACTIVATE
event. I suppose it should be put in the LOAD event and
then whenever the selection criteria is changed reset the
rowsource at that time.
Basically there are various selection criteria at the top
of the screen and the listbox below shows the results.
There is a 'refresh' command button to reload the listbox
after changes to the selection criteria. When an item in
the listbox is selected, another form is opened which may
result in deleting the selected row, thus a requery is
needed when returning.
I'm a relative beginner with VBA and am unfamiliar with
when events are triggered.
 
It is a single listbox.requery statement that is causing
the 'blip'. It is in the Activate event. If I remove this
one statement the listbox is not refreshed, if I resinsert
it, I get the 'blip' like its being refreshed twice.
Any ideas?
Should I use Docmd.Requery instead of Listbox.Requery ?
 
David said:
It is a single listbox.requery statement that is causing
the 'blip'. It is in the Activate event. If I remove this
one statement the listbox is not refreshed, if I resinsert
it, I get the 'blip' like its being refreshed twice.
Any ideas?
Should I use Docmd.Requery instead of Listbox.Requery ?

Hmm, I don't see why the list box wouldn't be requeried automatically if
you're setting the RowSource property in the Acvtivate event, as you
said originally. I'd have to see the event procedure to know if there's
a good reason for the "blip". Care to post it?

No, you shouldn't use DoCmd.Requery unless you want to requery the
entire form, not just the list box.
 
Back
Top