PDA

View Full Version : Filling a combox with a different query on a linked form



Blasphemer
11-30-2008, 03:48 AM
Hi,

I have a form in access linked with a table, which I made using design view. One of the field in the form is Owner_Name. We have about 20 people who can be possible owners, so I've kept their names in a separate table.

What I'd like to do is make that field a combo (drop down) box which'd get all owner names from that table. However still keeping the whole form linked with original table.

Is this possible?

OBP
11-30-2008, 05:11 AM
Not only possible but also desirable, however you do need a field in the Main Table that the Form uses to contain the ID of the Selected "Owner".
Ideally your Owners Table should have an Autonumber OwnerID Field and your main table should have a "Number - Type Integer or Long Integer" OwnerID field and the 2 tables should be "Joined" in the Relationships from the Owner Table to the Main Table with "Referential Integrity" which will make it a "One to Many" relationship.
On your main Table Form have the Combo (I would use a Query to supply it's data so that you can sort the names alphabetically) with OwnerID, LastName and FirstName, with it's Bound Column as the OwnerID and it's column width set to 0cm so that it is not visible. The "Control Source" should be set to the OwnerID on the form (from the main table).

Blasphemer
11-30-2008, 05:15 AM
Not only possible but also desirable, however you do need a field in the Main Table that the Form uses to contain the ID of the Selected "Owner".
Ideally your Owners Table should have an Autonumber OwnerID Field and your main table should have a "Number - Type Integer or Long Integer" OwnerID field and the 2 tables should be "Joined" in the Relationships from the Owner Table to the Main Table with "Referential Integrity" which will make it a "One to Many" relationship.
Yes I do have an owner_id feild in both tables.. however I do not know how to populate the combobox? what would i need to populate combo box with all owners, so the user can select one from the list?

OBP
11-30-2008, 11:03 AM
You populate it with a Query based on the Owners Table. You do so by using the Toolbox Combo Wizard to select the Query and also to assign the Control source to the Form's OwnerId.