populating fields on a form

  • Thread starter Thread starter stever
  • Start date Start date
S

stever

I have created a form with three combo boxes:

Group
Org
Item

I want to use the data that is selected from these combo
boxes as the source for these three fields, which are also
shown on the same form:

Field A
Field B
Field C

I am having trouble getting these three fields populated.
I have a table which has the six fields (Group, Org, Item,
Field A, Field B, Field C) and a query that is set-up to
QBF based on the data in the combo boxes.

For my output, I'd like the following functionality:
1. If a different Group, Org, or Item is selected from the
combo boxes, I want Field A, Field B, and Field C to
automatically populate and update.

2. I want the data that shows in the Field A, B, C to be
read only and not able to be changed.

Questions:
1. How should my three fields (Fields A, B, C) be set-up --
as combo boxes or as list boxes or as something else?

2. What needs to go in my Control Source, Row Source or
AfterUpdate fields in these six boxes?

3. What is the best way to make this work?

Thanks.
 
I'm unclear why you have duplicate fields in your table. If I understand
your description, whatever's in Group is also in FieldA, whatever's in Org
is also in FieldB, ...
 
Sorry for the confusion.

My table has six fields (with ~300,000 records):
Group
Org
Item
Field A (cost)
Field B (quantity)
Field C (value)

My form has these same six fields -- the first three are
combo boxes where a user can select the Group, Org, and
Item. The next three are boxes/fields where I want the
cost/quantity/value to show for the respective
Group/Org/Item record that is selected.

Does this help?
 
stever

One approach might be to use "cascading" comboboxes.

Add an AfterUpdate procedure to your Group combobox that requeries the Org
and Item comboboxes. The query that underlies the Org combobox uses the
value in the Group to narrow its list. Create an AfterUpdate procedure in
Org to requery the Item combobox. The underlying Item query looks to both
Group and Org as criteria.

Finally, in an AfterUpdate procedure in the Item combobox, requery the
form -- use a query under the form that refers to the three comboboxes as
criteria. This way, only a single record should load into the form, after
picking the third combobox (assuming your Group/Org/Item combination is
unique -- you haven't indicated primary keys).

One note -- don't bind the comboboxes to the underlying fields -- leave them
unbound. If you bind them, anyone can inadvertently change a record's
Group, Org and/or Item. Just use them to help look up items.
 
Back
Top