Populating text box based on Combobox selection?

NewShoes

Registered User.
Local time
Today, 11:33
Joined
Aug 1, 2009
Messages
223
Hey all,

This is probably pretty simple but I'm unsure how to do it. I have a combo box that lets me select staff, this is bound to StaffID. In the staff table I have a "Notes" field. What I would like is when I select a staff member from the combo box, for it to populate the text box with the notes against that staff member.

Thanks,
-NS
 
Use the Column(n) method to populate the textbox

RowSource "Select ID, Name, Notes From Table"

Me.Txtbox = Me.Combo.Column(1)

Don't forget columns are zero based.
 
Thanks for the quick reply David. However, would this mean that Notes would have to be part of the combo box? Would this not slow performance when making a selection if the notes were sizable?

Thanks,
-NS
 
Only testing can prove that, but that is the normal way to populate many unbound controls from a combo box.
 
I am trying to learn this as well. I have a combo box that is based off of Mgr Table. 2 fields, Manager & Vehicle #. So on the form when I select from the combo box Veh#, "V107", I would like the Vehicle operator (text box) to populate the field with the name from the Mgr Table. How would I go from here; I've not really not used all the uses of a combo box it seems. Thanks so much for any help.
 
NewShoes, I'm assuming that this "Notes" field is defined as a Memo Datatype since Text fields are limited to 256 characters and you speak of some notes as being 'sizable.' If this is true the field cannot be part of the Combobox. When using the Wizard to create a Combobox Access will not even make Memo Fields available for inclusion. If you don't use the Wizard but simply use a SQL statement to populate the Combobox, and include the Memo Field, Access will truncate its contents to 256 characters.

What you can do is to make a form for displaying your data and then, using the Combobox Wizard, select the third option "Find a record on my form based on the Value I selected in my combo box."

Access will generate the code to retrieve the record with the appropriate notes. There is one caveat, though; the field that you choose to retrieve the record by must be unique to that employee, such as an Employee ID.

The code Access uses for this utilizes FindFirst. If you were to try retrieving the record by the employees Last Name, for instance, and had employees

Smith, Anne
Smith, Jane
Smith, Xavier


assuming that the records are sorted by Last Name then First Name, Access would always retrieve the record for Anne Smith regardless of which Smith you selected from the Combobox.

Using a unique ID number gets around this.

If an ID number isn't available you can use a concatenated LastName /FirstName field to retrieve the record by, but that requires a little more work.

I have a short tutorial I can post here if you need to go this route, but even LastName/FirstName doesn't guarantee uniqueness.

Linq ;0)>
 
Last edited:
Thank you so much for your help. I want to make sure I'm clear on what I am trying to do. I have a table, Mgr Table, which includes the manager name, and the vehicle he drives so they are unique
Bob V001
Tom V002
etc.
The Mgr Usage Table contains the mileage; personal, business,fuel, etc. which is used to track all that information.
To create a data entry form to add records to the Mgr Usage Table I create a form that has a combo box based on the Mgr Table with the Veh # as a drop down. I wanted to create a text box for operator below the combo box that would populate with the operator assigned to that vehicle from the Mgr Table. Does that make sense?
 

Users who are viewing this thread

Back
Top Bottom