Starting a form with no available Where clause value.

H

H. Martins

I have a form.

That form has a Combo Box with a separate query.

All the other fields in the form use the form's query.

The form query is dependent on the Combo Box selection. When I start
the form it remains all gray.

I have done some tests and concluded that until I give some useful
value to the query's Where clause that results in, at list, one
record, it displays the form perfectly. After starting with some dummy
value the form responds perfectly to the combo box selection.

I would like the form to open showing blank fields (or similar) until
I select something in the combo box. Is there a way?

Thanks
Henry
 
H

H. Martins

Don't know if it is important but I made a mistake.

It is not a ComboBox but a ListBox.

I couldn't find the syntax to read the ListBox cursor position
directly in the query but I got a workaround by using a in-between
function.

As I said, I select a row in the ListBox and the form responds to
that. Nevertheless, the form only start if I arranje some dummy value
for the initial form Where clause (I do that in the in-between
function).

Henry
..
 
M

Marshall Barton

H. Martins said:
I have a form.

That form has a Combo Box with a separate query.

All the other fields in the form use the form's query.

The form query is dependent on the Combo Box selection. When I start
the form it remains all gray.

I have done some tests and concluded that until I give some useful
value to the query's Where clause that results in, at list, one
record, it displays the form perfectly. After starting with some dummy
value the form responds perfectly to the combo box selection.

I would like the form to open showing blank fields (or similar) until
I select something in the combo box. Is there a way?


If you can allow additions, the form should open normally to
a blank new record.
 
H

H. Martins

Marsh,

In that case I should not allow generation blank or somehow nonsense
records, unless I find some way to force an "Escape".


Mike,

I've tried that before. It works OK but, before applying a recordset,
I couldn't find a way to avoid the "unbound" message in every field.

Thanks
Henry
 
M

Marshall Barton

H. Martins said:
In that case I should not allow generation blank or somehow nonsense
records, unless I find some way to force an "Escape".


If the form has no records to display and new records are
not allowed, then there is not much for the form to do.
(You can use the form's BeforeUpdate event to validate data
values and cancel the update if they're no good) The bottom
line is that you can not display blank fields unless you
allow additions. (I think displaying an arbitrary record is
not a good UI)

I suppose that you could make all the controls unbound and
then use code to bind them when something is selected in the
combo box, but this also seems kind of hokey.

If you open the form using the OpenForm method's
WhereCondition argument so that no records are displayed
(e.g. "key=0"), then the combo box's AfterUPdate event can
filter the report by just changing the Filter property.

Make sure that the combo box is in either the form's header
or footer section or it won't appear and you won't be able
to select a record.
 
M

Mike Painter

H. Martins said:
Marsh,

In that case I should not allow generation blank or somehow nonsense
records, unless I find some way to force an "Escape".


Mike,

I've tried that before. It works OK but, before applying a recordset,
I couldn't find a way to avoid the "unbound" message in every field.

Thanks
Henry

You would create the form with recordset equal to a copy of the query you
use but without the criteria.
In the list box you would change the recordset to the query with the
criteria in place.
 

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