Problem when query returns no records

P

piet

I have created a continues form, based on a query. In the header, there are
some comboboxes that gives the user the possibility to make certain
selections. Everytime a selection is made on a combobox, there is a VBA
action: ME.REQUERY. That works very fine: the user sees always the result of
his selection(s). There is also a textbox in the header that shows the
number of records in the form (Therefore I use DCOUNT).
Now I've got two problems, when the query returns no records (because the
user choose a selection of items that aren't in the database):

1. The textbox is not updated (should show 0 records).

2. The combobox where the last selection has been made, becomes empty????

I thought I could interfere with some code after the requery, but that don't
works. Is there any idea how to check if the underlying query returns no
records and do some action before updating the form? I can by example show a
message to the user: "there are no records that match your criteria".

Txs
Piet
 
J

JohnFol

When the selection is made, you do the me.requery. Before the me.Requery you
could do:

If DCount("*", "QueryFormIsBasedOn") = 0 then
'Inform the user "there are no records that match your criteria".
Else
me.requery
end if
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top