Group:  Microsoft Access ยป microsoft.public.access.macros
Thread: Autofill fields based on other fields' responses

DotNetBag
.NET Development Newsgroups

HTVi
TV Discussion Newsgroups

Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
Rising Antivirus 2006

Autofill fields based on other fields' responses
Danny 06.07.2006 00:01:02
In a table, is it possible for one field to auto-fill itself based on the
previous field's entry? For example, I have two look-up fields, and both are
filled with data. I would like to have the second field choose the entry that
would be linked with the first field automatically, based on the selection I
make in the first field.

So for example, the data is linked like: Field one: Cookie, Field Two:
requires flour and sugar. Is it possible to have the second field choose that
associated answer automatically, after I have chosen cookie for the first
field?

Thanks!
Re: Autofill fields based on other fields' responses
Steve Schapel <schapel[ at ]mvps.org.ns> 06.07.2006 00:10:08
Danny,

The answer to this depends on your answer to this... Is there always
only one possible entry in Field Two for any given entry in Field One?

--
Steve Schapel, Microsoft Access MVP

Danny wrote:
[Quoted Text]
> In a table, is it possible for one field to auto-fill itself based on the
> previous field's entry? For example, I have two look-up fields, and both are
> filled with data. I would like to have the second field choose the entry that
> would be linked with the first field automatically, based on the selection I
> make in the first field.
>
> So for example, the data is linked like: Field one: Cookie, Field Two:
> requires flour and sugar. Is it possible to have the second field choose that
> associated answer automatically, after I have chosen cookie for the first
> field?
>
> Thanks!
Re: Autofill fields based on other fields' responses
Danny 10.07.2006 09:09:02
For the most part yes. Would it be possible to add that additional
functionality, of having a few different responses available to fill in field
two, based on field one?

"Steve Schapel" wrote:

[Quoted Text]
> Danny,
>
> The answer to this depends on your answer to this... Is there always
> only one possible entry in Field Two for any given entry in Field One?
>
> --
> Steve Schapel, Microsoft Access MVP
>
> Danny wrote:
> > In a table, is it possible for one field to auto-fill itself based on the
> > previous field's entry? For example, I have two look-up fields, and both are
> > filled with data. I would like to have the second field choose the entry that
> > would be linked with the first field automatically, based on the selection I
> > make in the first field.
> >
> > So for example, the data is linked like: Field one: Cookie, Field Two:
> > requires flour and sugar. Is it possible to have the second field choose that
> > associated answer automatically, after I have chosen cookie for the first
> > field?
> >
> > Thanks!
>
Re: Autofill fields based on other fields' responses
Steve Schapel <schapel[ at ]mvps.org.ns> 10.07.2006 09:28:32
Danny,

You would need a "master" table that references all possible
combinations of Field One and Field Two. And probably also a single
field table that lists all the possible Field One values.

So, for example...

Table: Products
one field - Product
data something like this...
Cookie
Pancake
Tart

Table: Ingredients
two fields:
Product
Ingredient

data something like this...
Cookie flour
Cookie sugar
Cookie milk
Pancake flour
Pancake butter
Tart flour
Tart sugar
Tart fruit

Ok, then the standard way to do this on your form is via "cascading
comboboxes". Make a combobox which uses the Products table as its Row
Source. Then make another combobox, using a query based on the
Ingredients table, but uses the first combobox in its criteria. The SQL
view of such a query might be like this...
SELECT Ingredient FROM Ingredients
WHERE Product = Forms![YourForm]![Product]

You need a macro or VBA code on the After Update event of the first
combobox to Requery the second combobox.

There are other considerations if this is on a continuous view form, but
the obove general approach is fine on a single view form.

--
Steve Schapel, Microsoft Access MVP

Danny wrote:
[Quoted Text]
> For the most part yes. Would it be possible to add that additional
> functionality, of having a few different responses available to fill in field
> two, based on field one?

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