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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combo Box and data field display

Status
Not open for further replies.

DougNaf

Programmer
Jun 2, 2005
32
US
I am a new user to Access (2002). I have an owner database using a simple form and i want to use a combo box to select the owner, then when I tab off the box have the form display the various fields from the owner database. Do i need some VBA code added and to what event?

Thanks in advance!
 
Have you tried using the form wizard with the table that contains the details? You can then use the combobox wizard to create a combobox that finds records in your table.
 
Thanks for your suggestion. I created a new form using the wizard,then deleted the owner field and then added a combo box (owner field)using the wizard. The wizards seemed to work fine, but now when i display the form, the owner number works in the combo box, but the fields do not change to correspond to the owner #. Also I hope to eventually be able to pull down an existing owner on the form as well as add a new owner. Will that work with the combo box?

Thanks for your help!
 
the fields do not change to correspond to the owner #.
Can you post the wizard generated code, please?

Also I hope to eventually be able to pull down an existing owner on the form as well as add a new owner.
Will that work with the combo box?
Yes it will. You can leave the owner number on the form and to blank the combo after a search or synchronise the combo with your form. The first option is the easiest to code.

You will need to requery the combo when you add a new owner, but that is quite simple to do:

Me.ComboName.Requery
 
Since i am new to access, i am not sure how to generate the wizard code, but below is how I answered the questions:

1 - I want the combo box to lookup the values in a table or query.
2 - Table:Owner
3 - Selected Owner and Name
4 - unchecked the "Hide key column"
5 - selected the "Remember the value for later use and NOT the "Store that value in this field"
6 - Finish

Thanks
 
Your first answer was wrong. It should have been "Find a record on my form based on the value I select in my combobox".

You can view code by clicking on a form in the database window and then clicking on the colourful code icon. It is always wise to examine the code, if you wish to learn about Access and VBA.
 
I made the change on the first answer and the program now works!

THANK YOU very much!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top