Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Autopopulating fields in a form

Status
Not open for further replies.

CMooreJr

Technical User
Feb 20, 2003
217
US
Hey guys! I want to have the user choose a company from a drop down box. This box pulls from the "COMPANY" table. I want the address, phone number, etc to automatically populate the corresponding fields in the form. (This data is also stored in the "COMPANY" table. How can I accomplish this? I have pulled it off before but cant remember how I did it.

Thanks!
 
In the After Update event of your combo box you will have some code that will check to see what the selected value is. And then based on that value, you will have some more code that will pull the necessary info from your db and fill in the combo boxes.

Does this help? Let me know if you need help with the code.
 
Hey Jason...yeah, I'll need help wiht the code...that is my big problem...I can do thigs with queries and such, but I'm still a beginner when it comes to VBA...thanks for your help! All the other boxes are simply text boxes, so I was hoping it would be something rather simple that could be put in the record source field....I know I have done it before, but I dont hvae access to that database anymore....
 
Is the primary key of the table that contains COMPANY a numerical ID, or is the name of the company the primary key.

If it is numerical, do you use this key in your drop down, or does it only contain the text name of the company?
 
turn on the wizards (wand icon on toolbox in design view)

open a new form in design view, right click set record source to the table, or a query that pulls all values from table.

draw a combo box, select option 3 when wizard pops up, that is "find record based on my selection" or words to that effect, follow the prompts

then just drag the required fields onto the form, fancy it up and hey presto.

and all without complicated code that us mere mortals dont understand :p
 
Silly...YOU ARE THE MAN! How in the Heck have I missed this all these years! Now all I need to do is find out how to link the cbobox to the subform where it pulls all the right records and I am done! Thanks for your help! Have a star!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top