Creating a textbox in access to lookup values?

I am totally new to learning vba and access. If someone could teach me that would be appreciated. I have a command button and text boxes. Basically, I want to enter a value in the text box, and populates the rest of the text boxes related to that value.
Joseph SAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Daniel PineaultPresident / Owner CARDA Consultants Inc.Commented:
A little more context might help, but if the information is already in the database and you want to pull it up, you'd be better served using a combo box.  Please explain further and well do our best to help you get there.  Can you provide a concrete usage example.  A screenshot of your form.
PatHartmanCommented:
I'll give you a concrete example and you do the same for your situation.

On an order form, you choose a customerID from a combo box, your code then takes the shipping address fields from the combo's rowSource and places them into the ShipTo fields.  This set up allows us to have a permanent shipping address which is stored in the customer record but provides a way to over ride the ship to address for any given order.

In the AfterUpdate event of the CustomerID combo:

Me.ShipToAddr1 = Me.cboCustomerID.Column(5)
Me.ShipToAddr2 = Me.cboCustomerID.Column(6)
Me.ShipToCity = Me.cboCustomerID.Column(7)
Me.ShipToState = Me.cboCustomerID.Column(8)
Me.ShipToZip = Me.cboCustomerID.Column(9)


The RowSource of the combo is a zero based array.  The column numbers I used were arbitrary.  You would create the RowSource query and count the columns you selected.  The column # used above will be the ordinal number - 1 because the column index starts with0.  So field1 is .Column(0), field2 is .Column(1), etc.
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
Be sure you're storing this data correctly. Pat's example of a Shipping address is valid, but in many cases you do not want to store data like this in "child" tables. Instead, you'd store the ID value of the "parent" record, and then pull data from that record as needed.

For example, in an Ordering system you'd typically have an Order_Header and an Order_Detail table structure. In the Order_header table you'd store a link to a Customer record, but you would NOT store the Customer's Name and such in the Order_Header table. By storing the ID value from the Customer table in Order_Header, you could always retrieve that data from the Customer table.

Same with Order_Detail. You would store the ID value from Order_Header in the detail table, but you would not store things like the Order Number, Order Date, Customer, etc. The link to the Order_Header table would be sufficient for you to pull that data when needed.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Access 2016

From novice to tech pro — start learning today.