mhegazy
mhegazy

Reputation: 57

access combo box on a form to display text values from table/query and save the associated ID value in the table on my form is already based on

My project is a form based on a transaction table, this form has four combo boxes. Basically all of them are storing ID values, and the question is how to make access display the associated value of the ID on the form, while the ID# is being stored in the table.

Example: one combo name is well_ID on the form, which will be populated from the table (Wells) by select staetment [SELECT Wells.Well_ID, Wells.Wellname FROM Wells] i need the combo to display the well name and store the well_ID in the table.

Would you please help on this.

Regards Mohamed

Upvotes: 0

Views: 4134

Answers (1)

Fionnuala
Fionnuala

Reputation: 91316

The easiest way to do this is to use the wizard and let it guide you through. Create a form based on a table or query, ensure the wizard button is clicked, add a combo and follow the steps provided by the wizard.

You will end up with something on these lines:

 Row Source Type : Table/Query
 Row Source      : SELECT Wells.Well_ID, Wells.Wellname FROM Wells 
 Bound Column    : 1
 Column Count    : 2
 Column Widths   : 0cm;2cm;

If you choose to store the value in a field (column), you will need:

 Control Source  : SomeID 

Which refers to the field or column on in the table or query bound to the form and takes its contents from the Bound Column, which can be any valid column number, starting from one (1). In other words, what ever field in that table that should store Well_ID.

The Row Source can be a more complicated SQL string, a query or table. It can refer to other controls on any open form. These properties can be set by code.

Upvotes: 1

Related Questions