form not dispalying when query empty

L

lordy16

Hi All,

I"m having a problem with Access 2007...

I have a form that is based on a query which contains a parameter. When the
query returns an empty dataset, the form does not display. only the form
header, nothing in the deails section, no controls, buttons, nothing at all

Is this easily fixed? is there an option somewhere? is there a way i can
display an alert and cancel the operation so the user isn't displayed with a
completely blank screen?

Cheers
Chris
 
J

Jeanette Cunningham

lordy,
parameter queries do have some undesirable side effects.
Instead of a parameter query, use a combo box in the form's header.
When the user chooses a value from the combo, the form shows that record or
records.

Here is a link that shows how to do this

http://www.allenbrowne.com/ser-03.html

Jeanette Cunningham
 
R

Rick Brandt

lordy16 said:
Hi All,

I"m having a problem with Access 2007...

I have a form that is based on a query which contains a parameter.
When the query returns an empty dataset, the form does not display.
only the form header, nothing in the deails section, no controls,
buttons, nothing at all

Is this easily fixed? is there an option somewhere? is there a way i
can display an alert and cancel the operation so the user isn't
displayed with a completely blank screen?

Your query produces a non-editable recordset. When a form has no records to
display and no ability to add new ones a totally blank detail section is the
result.

This behavior is the same when looking at a query datasheet. When you have
a query that allows you to add new records and with criteria that returns
zero rows you still get the blank "new row". However a non-editable query
that returns zero rows will return no rows at all. Imagine that "no rows at
all" displayed in a form. That is what you are seeing.

This is how it has always been, but displaying a form bound to a query
returning zero rows and which is also non-editable happens infrequently
enough that people are not accustomed to seeing this blank result.
 
L

lordy16

Hi Rick,

Thanks very very much for that explaination, that really helps me understand
what's going on. But how can I change my query to one that allows me to add
records? It's probably staring me in the face as always but I don't seem to
be able to find it

Thanks again for your help, much appreciated.

Chris
 
R

Rick Brandt

lordy16 said:
Hi Rick,

Thanks very very much for that explaination, that really helps me
understand what's going on. But how can I change my query to one that
allows me to add records? It's probably staring me in the face as
always but I don't seem to be able to find it

Thanks again for your help, much appreciated.

In fact most queries are not editable, but simple SELECT queries often are
and there are rules that dictate when a SELECT query is editable and when it
is not. These rules are not that straight-forward and obvious though.

If your query uses Grouping or DISTINCT then it will absolutely 100% of the
time produce read-only results. If it includes more than one table then
that can easily cause a read-only result, but often with some design
tweaking such a query can be made editable. The more tables you include the
less likely that an editable result is possible or even desirable. In some
cases making edits in such a query applies the changes to the wrong table
than what you intended (especially deletes).

There is an entire help topic that discusses what makes queries editable or
not that you can read to see if it helps your situation.
 
Top