Hey,
Thanks to Tim for his short, yet logical answer.
We've put this in a condition in the macro (please don't laugh, we use what
we know). And it does work. If you click the command button on the Main form
(where the cmdButton is located), the message box appears if there are no
records. The form never displays. All is well.
But we have to open the called form in Hidden mode so that the program can
actually "see" the control - the ListBox that it's checking.
If the condition - If lstMyListBox.listcount = 0 - evaluates to true, the
Msgbox is displayed, the macro ends. The form is never displayed.
But the next time we run this we still get the Msgbox (even if the query now
returns records). We've determined that the form does not unload itself, and
the close command (or DoCmdClose) doesn't seem to work. In other words, the
"hidden form" (and its variables?) are still lingering. We've tested this.
We've reset the query so it returns results. We open the form. Nothing in
the listbox. We close the form and open it again. Now it's back to normal
(the returned query records appear in the Listbox).
It appears we need to find some way to unload a hidden from, and/or Set it
to Nothing, so the variables are cleared.
The macro tools are limiting, but when we've tried coding we can't seem to
get the right combination or sequence.
Thanks to all for the great discussion here, and your patience.
"Tim Marshall" <TI****@PurplePandaChasers.Moertherium> wrote in message
news:d8**********@coranto.ucs.mun.ca...
Trevor Best wrote:
LeighP wrote:
If .EOF And .BOF Then
Beware: I've recently had instances where both .BOF and .EOF were false
yet there were no records, I use .RecordCount to check this now.
Hmmmm, actually, for a list or combo box, I'd use neither method.
My preference is to use the listcount property for the list box:
If lstMyListBox.listcount = 0 then '1 if headers are used
msgbox "hi there"
end if
This works whether your rowsource is a "Table/Query" or "Value List".
Do not use the method Beacher suggested.
--
Tim http://www.ucs.mun.ca/~tmarshal/
^o<
/#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^ "Whatcha doin?" - Ditto "TIM-MAY!!" - Me