Autofill fields by selecting a record in a combo box

  • Thread starter Thread starter Art at ABE Computer Consultants
  • Start date Start date
A

Art at ABE Computer Consultants

I have a subform that has several fields. For instance, "scientific
name," "common name," "size," and "cost" These refer to plants used
in quoting a landscaping job. All this data is found in a lookup
table, but there are lots of plants. So--with a combo box that looks
up the "scientific name", I wish to bring in the other 3 fields to the
form after choosing the correct name. I can then add a "quantity" and
do some math and get the total cost for each plant.

For the life of me, I can't remember how to populate the fields after
I do a lookup in the combo box. Does anyone have the answer?

Thanks---Art
 
You have a couple of choices
1. If the query that populates the combo box returns all
the fields you want into separate columns you can use

txtDetail.Value = yourcombo.column(x,yourcombo.listindex)

2. if not, use
txtDetail.vaule = dlookup
("DetailField","detailTable","DetailPrimaryKey = " &
yourcombo.column(x,yourcombo.listindex))

in both cases the code should go in combo box click event
 
OK, I'll give it a try. I also had an IQ surge yesterday reading a
post by someone else--I can just use the relational database like it
is intended to be used. I can assign a key to the primary field or
perhaps the autonumber field and store the info that way. As long as
the values in the lookup table don't change before the estimate it
made.

That way, we can display records for the user, and for the actual
estimate, just do a report.

I hope

Thanks

Art
 
Back
Top