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

Combo box - display more than one field

Status
Not open for further replies.

sankalpa

Instructor
May 12, 2003
8
GB
Hi y'all,

MS Access 5
Database: Film Awards
Combo box accesses Query: AwardID, Ceremony Name, Award Name
- e.g. 1233, Razzie, Worst Actor

Combo box properties:
Column count: 3; Column widths: 0;2cm;2cm; Bound column: 1

Problem: 'Ceremony Name' and 'Award Name' are listed in two columns BUT after a selection is made only 'Ceremony Name' is displayed in the control box.
Can I display two fields in a combo box?
 
The combo box in it's collapsed form is just a text box control so it cann't display two separate fields.

However, two options come to mind
In the AfterUpdate event of the combo box you can put some code that puts the AwardName data into an extra text box control that you can position appropriately near to the combo box

Alternatively
In the combo box RowSource you change the query to
"SELECT AwardID, Ceremony Name & Award Name As TextPart FROM tblAwards"
and change the Column Count to 2
and change the ColumnWidths to 0;4cm



Both options have some advantages and disadvantages - olny you can decide.


'ope-that-'elps.





G LS
accessaceNOJUNK@valleyalley.co.uk
Remove the NOJUNK to use.
 
You can do this by changing the "Row Source" for the combo box to a query rather than direct from a table. Here is an example that I used to display UserLastname, Userfirstname from a combo box.

SELECT Users.UserID, [UserLname] & " " & [UserFname] AS Expr1 FROM Users;

You will have to change your Column Count to 2 and Change your Column Sizes for your needs.

If you're not sure how to create a query for the "Row Source" of a combo box, just click on the elipse "..." button next to the field in the Object Properties window.

Hope this helps.

LillyPad
 
Thanks to LittleSmudge and lillypad for such a speedy solution. Joining the two strings as str for display solves the problem.

sankalpa
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top