Group:  Microsoft Access ยป microsoft.public.access.formscoding
Thread: Starting a form with no available Where clause value.

Geek News

Starting a form with no available Where clause value.
"H. Martins" <HJRMartins[ at ]gmail.com> 12/3/2008 5:39:54 PM
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
Re: Starting a form with no available Where clause value.
"H. Martins" <HJRMartins[ at ]gmail.com> 12/3/2008 6:20:57 PM

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
..
Re: Starting a form with no available Where clause value.
Marshall Barton <marshbarton[ at ]wowway.com> 12/3/2008 7:20:11 PM
H. Martins wrote:

[Quoted Text]
>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.

--
Marsh
MVP [MS Access]
Re: Starting a form with no available Where clause value.
"Mike Painter" <mddotpainter[ at ]sbcglobal.net> 12/3/2008 7:21:12 PM
H. Martins wrote:
[Quoted Text]
> 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

You need to start the form without the selection and change the recordset
after a selection is made.


Re: Starting a form with no available Where clause value.
"H. Martins" <HJRMartins[ at ]gmail.com> 12/3/2008 8:51:45 PM
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
Re: Starting a form with no available Where clause value.
Marshall Barton <marshbarton[ at ]wowway.com> 12/3/2008 10:06:02 PM
H. Martins wrote:
[Quoted Text]
>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.

--
Marsh
MVP [MS Access]
Re: Starting a form with no available Where clause value.
"Mike Painter" <mddotpainter[ at ]sbcglobal.net> 12/4/2008 12:29:55 AM
H. Martins wrote:
[Quoted Text]
> 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.


Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net