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

Table display in Combo box

Status
Not open for further replies.

7Oclock

Programmer
Mar 9, 2005
12
0
0
US
I would like to display one field of a table in a combo box but write another field to the database. What is the easiest way to do this?
 
Use the wizard to create the combo box on your form and answer the prompts accordingly.

Greg
"Personally, I am always ready to learn, although I do not always like being taught." - Winston Churchill
 
7Oclock

Welcome to Tek-Tips

traingamer / Greg has wisely suggested for you to use the ComboBox wizard.

To supplement this, there are several things to be aware of with Combo and List boxes.

Open the form in design mode and make sure the "Properties" window is open (from the menu, "View" -> "Properties")

Select your combo box and look at the "Data" tab in the Properties window.

ControlSource: If the field is "bound" to a table, this field will indicate the name of the field the value of the combo box is bound to. If there is no entry here, then the combo box control is considered "unbound".

RowSource: Often a SQL SELECT statement. Click on this field and then select the "..." command button that appears to the right to open the QueryBuilder. Here, the SQL statement can consist of one or more than "columns". The order of the "columns" is important.

If you used the Combo box wizard to create the combo box, you will probably have two columns -- the field name you selected PLUS the primary key field which will most likely be in the first column. This is an important point to consider when creating a combo box.

Close the QueryBuilder.

BoundColumn: Specifies the column in the SQL SELECT statement from the RowSource that is "bound" to the "ControlSource".

Now click on the "Format" tab.

ColumnCount: Number MUST match the number of columns in RowSource

ColumnWidths: specifies the widths for each column. Hide a column by using 0" width. For example,
0";1"
Will hide the first column and display the second column.

Richard
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top