Listbox contents do not show..

  • Thread starter Thread starter Bob Howard
  • Start date Start date
B

Bob Howard

Hi (Access 2003..),

I have an unbound listbox I use to get some info from a user (by merely
selecting a row). The listbox, and its contents show properly.

There's an "after update" event for this box where I gather and analysze
some info, such as the row number and the content of various columns.

So far so good.

I've recently added some code that sometimes issues a warning message (based
on circumstances). This is done as a msgbox with some verbage and which
simply contains an OK button.

The problem is that when the msgbox appears on the screen, the entire
contents of the listbox goes away --- and only re-appears after the OK
button is clicked (again, this is all in the after update event).

Is there amy magic I can apply so that the listbox contents remain visible
while the msgbox panel is on the screen??

Bob
 
Bob said:
I have an unbound listbox I use to get some info from a user (by
merely selecting a row). The listbox, and its contents show properly. [snip]
The problem is that when the msgbox appears on the screen, the entire
contents of the listbox goes away --- and only re-appears after the OK
button is clicked (again, this is all in the after update event).
[snip]

Here is what I see (Access 97)...

If I have the ListBox in the center of my Access window such that the MsgBox
covers it up when opened then I see a blank ListBox when I move the MsgBox out
of the way. If I have the ListBox positioned so that the MsgBox does not
obscure the ListBox I still see the rows, but I can drag the MsgBox over the
ListBox and it will "erase" the contents. This tells me that this has to do
with how Access is painting and updating the screen. That likely means you
cannot change this behavior.

I also tested using a small form as a replacement for the MsgBox. If I use the
acDialog argument to open the form as a modal dialog then the behavior is the
same as it is with a MsgBox. If I open the form without using acDialog then the
ListBox contents are not erased.

You can even set Popup and Modal to true on the second form and the ListBox is
still not erased so unless you need the code-pausing behavior that a dialog
provides then that solves your problem. In your case though it sounds like you
DO need the code-pausing behavior, but with a form and the acDialog option you
can at least control where the dialog form appears on the screen and that might
work for you.

Can you explain why the user needs to be able to see the contents of the
ListBox? That might bring other options into play.
 
Thanks, Rick...

My form is a modal popup (as are about 99% of the forms in my applications).
It's not opened acDialog.

The ListBox is near the top of the form and isn't covered at all when the
msgbox opens.

Another strange quirk that I started noticing yesterday is that (depending
on the sequence of the code in the after update event), sometime the listbox
is NOT erased when a row is clicked THE FIRST TIME after the form opens ...
but does get erased on all subsequent clicks. This is repeatable ... if I
close the form and open it again, the listbox doesn't get erased the first
time it's clicked and then starts getting erased again on subsequent clicks.

But if I change the sequence of the code in the after update event a bit,
the listbox starts getting erased even on the first click.

A very strange problem!

Just for laughs, however, I just made a very simple change to the code that
seems to have totally cleared up the problem! The first line of code in the
after update event was a setfocus. I move the focus to a dummy control on
the screen (one the user cannot see) ... and the last line of code in the
event moves the focus to the control the user's most likely to need next.
My simple change was to comment out that initial setfocus!

Again, a very strange problem! But now "solved" ... !

Thanks.. Bob

Rick Brandt said:
Bob said:
I have an unbound listbox I use to get some info from a user (by
merely selecting a row). The listbox, and its contents show properly. [snip]
The problem is that when the msgbox appears on the screen, the entire
contents of the listbox goes away --- and only re-appears after the OK
button is clicked (again, this is all in the after update event).
[snip]

Here is what I see (Access 97)...

If I have the ListBox in the center of my Access window such that the
MsgBox covers it up when opened then I see a blank ListBox when I move the
MsgBox out of the way. If I have the ListBox positioned so that the
MsgBox does not obscure the ListBox I still see the rows, but I can drag
the MsgBox over the ListBox and it will "erase" the contents. This tells
me that this has to do with how Access is painting and updating the
screen. That likely means you cannot change this behavior.

I also tested using a small form as a replacement for the MsgBox. If I
use the acDialog argument to open the form as a modal dialog then the
behavior is the same as it is with a MsgBox. If I open the form without
using acDialog then the ListBox contents are not erased.

You can even set Popup and Modal to true on the second form and the
ListBox is still not erased so unless you need the code-pausing behavior
that a dialog provides then that solves your problem. In your case though
it sounds like you DO need the code-pausing behavior, but with a form and
the acDialog option you can at least control where the dialog form appears
on the screen and that might work for you.

Can you explain why the user needs to be able to see the contents of the
ListBox? That might bring other options into play.
 
Bob said:
Thanks, Rick...

My form is a modal popup (as are about 99% of the forms in my
applications). It's not opened acDialog.

I was talking about using a second form opened with acDialog instead of a
MsgBox. It doesn't matter what the first form is.
The ListBox is near the top of the form and isn't covered at all when
the msgbox opens.

That is different than what I saw then. Perhaps a difference in Access
versions.
Another strange quirk that I started noticing yesterday is that
(depending on the sequence of the code in the after update event),
sometime the listbox is NOT erased when a row is clicked THE FIRST
TIME after the form opens ... but does get erased on all subsequent
clicks. This is repeatable ... if I close the form and open it
again, the listbox doesn't get erased the first time it's clicked and
then starts getting erased again on subsequent clicks.
But if I change the sequence of the code in the after update event a
bit, the listbox starts getting erased even on the first click.

A very strange problem!

Just for laughs, however, I just made a very simple change to the
code that seems to have totally cleared up the problem! The first
line of code in the after update event was a setfocus. I move the
focus to a dummy control on the screen (one the user cannot see) ...
and the last line of code in the event moves the focus to the control
the user's most likely to need next. My simple change was to comment
out that initial setfocus!
Again, a very strange problem! But now "solved" ... !

Thanks.. Bob

Good to hear.
 
Back
Top