Combo box that displays field from another table

G

Guest

I have the following 2 tables.
1. Company Table - with fields "CoID" & "CoName"
2. Events Table - with fields "EventName" & "CoID"

I've created a form based on Events Table, and want to add a field that
displays the respective CoName from Company Table.

I've tried to create a combo box based on a query linking CoID from Events
Table & CoName from Company Table. Also, I've used the following code,
wishing to display the correct CoName in combo box in respect to the "CoID"
in the form.

Private Sub Form_Current()
ComboCoName = CoID
End Sub

However, only the CoID is displayed in the combo box instead of the CoName.
Please help. Thanks.
 
V

Van T. Dinh

If you use CoID, CoName in that order as the RowSource of your ComboBox then
you need to set the ColumnWidths Property of the ComboBox with the width of
the first Column to zero.

Access ComboBox always so the first visible Column. Hence if you want to
show the second Column value, you must set the width of the first Column to
zero.

Check Access Help on the Column Widths Property.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top