Auto Populate

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is there a way that you can auto populate a text box when you choose
something in a drop down box?
 
There's a couple of ways.

One is to use the AfterUpdate event of the combo to set the value of the
text box. To see an example, open the Northwind sample database, the Orders
Subform, and look at the ProductID combo. Its AfterUpdate looks up the
current price of the product, and drops it into the text box for price.

The other way is to just use the text box to show what is in one of the
other columns of the combo's RowSource. For example, if the value you want
is in column 2 of the combo, you would set the Control Source of your text
box to:
=[Combo1].Column(1)

(Note that the first column is zero, the 2nd is 1, and so on.)
 
Hi Allen,
I have a variation of the same problem as KRDitch. My problem is that I have
various field box from the same record source, but when I choose the ID, the
other info does not auto populate when it suppose to. I've tried following
the northwind database method but it still doesn't work. Can you provide me
insight? thanks

esca007

Allen Browne said:
There's a couple of ways.

One is to use the AfterUpdate event of the combo to set the value of the
text box. To see an example, open the Northwind sample database, the Orders
Subform, and look at the ProductID combo. Its AfterUpdate looks up the
current price of the product, and drops it into the text box for price.

The other way is to just use the text box to show what is in one of the
other columns of the combo's RowSource. For example, if the value you want
is in column 2 of the combo, you would set the Control Source of your text
box to:
=[Combo1].Column(1)

(Note that the first column is zero, the 2nd is 1, and so on.)

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

KRDitch said:
Is there a way that you can auto populate a text box when you choose
something in a drop down box?
 
See:
Calculated fields
at:
http://allenbrowne.com/casu-14.html

The article explains that you do not want to duplicate data across mutliple
tables, unless there could be a meaningful reason why the different copies
could be validly different from each other. And if that does apply, it
explains how to use the AfterUpdate event of each control to assign the
value.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

esca007 said:
Hi Allen,
I have a variation of the same problem as KRDitch. My problem is that I
have
various field box from the same record source, but when I choose the ID,
the
other info does not auto populate when it suppose to. I've tried following
the northwind database method but it still doesn't work. Can you provide
me
insight? thanks

esca007

Allen Browne said:
There's a couple of ways.

One is to use the AfterUpdate event of the combo to set the value of the
text box. To see an example, open the Northwind sample database, the
Orders
Subform, and look at the ProductID combo. Its AfterUpdate looks up the
current price of the product, and drops it into the text box for price.

The other way is to just use the text box to show what is in one of the
other columns of the combo's RowSource. For example, if the value you
want
is in column 2 of the combo, you would set the Control Source of your
text
box to:
=[Combo1].Column(1)

(Note that the first column is zero, the 2nd is 1, and so on.)

KRDitch said:
Is there a way that you can auto populate a text box when you choose
something in a drop down box?
 
Have you ever figured this out? I was having the same problem with trying to
get data to populate into the text box. I followed the advice of putting
referring the 2nd column of the combo box. However, when I enter another
record, It changes all the previous entries to the current entry for the
combo box and the text box.

What's the recordsource of this form (evidently a continuous form),
and what's the rowsource of the combo box? You may have better luck
including the Combo's table in the Query upon which the form is based,
and display the field from the joined table.

John W. Vinson[MVP]
 
I've not been able to get anywhere with this.

When I type in =[TableName].Column(0) into the Control Source, brackets are
put around the word Column. I get the Name? error. I've tried adding it as
code in After Update, but just get blanks.

Any idea what I'm doing wrong?
Thanks!
-Pat
 
I've not been able to get anywhere with this.

When I type in =[TableName].Column(0) into the Control Source, brackets are
put around the word Column. I get the Name? error. I've tried adding it as
code in After Update, but just get blanks.

I don't think anyone suggested that. Tables don't have a Column()
property, and you can't refer to them by the table name in any case!

This syntax works if you put the name *of a Combo Box on the form* in
place of TableName.

John W. Vinson[MVP]
 

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

Similar Threads

Creating forms w/combo boxes 1
Look up boxes 5
Auto Populate. 1
Auto Populate 3
Auto Populate a static date 2
combo box selection overwrite issue 3
autofill/populate a table via form input 1
Auto Update Text box 1

Back
Top