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

Multiple fields in rowsource combobox property

Status
Not open for further replies.

murpl

Technical User
Mar 1, 2001
32
0
0
CA
I've done this as per Access help descriptions and examples but it doesn't seem to work...
What I'm trying to do is select from multiple collumns in a table (or query; same non result) but all I get in the forms combobox is the value from the first field specified.
Here's the SQL statement:
Code:
SELECT Employees.FirstName, Employees.LastName, Employees.JobTitle FROM Employees ORDER BY Employees.LastName;
All that shows up in the combobox is the values from FirstName. Am I going about this the wrong way? Access help says that this is the way to do it.
Thanks,
Mike
 
No you're right. You just have to set the folloing ComboBox properties:


Under the Format tab:
Column Count: 3
Column Widths: (as an example only) 1,1,1
List Width: (as an example only) 3

Under the Data tab:
Bound Column: this one tells access which one is the "data" column. Only one column can be bound to a ComboBox or ListBox but you can do things to save all the data if you need
 
"Only one column can be bound to a ComboBox or ListBox but you can do things to save all the data if you need"

I assume the "things" would be VB code, huh? I've been trying to work that out but I am kinda new to this and it isn't really all that important in this case. I'd welcome any hints but for now I'll play with it in between more important tasks.
Thanks for pointing me in the right direction about the property settings. I've tried various combinations and I'm getting a pretty good grip on how they affect things.
Much appreciated!

Mike
 
Couple of hints:

1) Typically, I use a "Primary Key" value as the bound column. In your case maybe add the employee# to the query(?). But you also don't want to see this number all the time so you set the column width for this to zero. It's there & bound but unseen. I also do this for other columns that I don't want to see but I want to get at their data in vba.

2) To get at the other columns you use the Column poperty of the listBox/comboBox. 1st column is numbered zero. Notation is like:

Me.myComboBox.Column(2) 'this will get the jobTitle in your query

3) VBA numbers columns starting at zero but the properties box starts at one. So for the porporties box JobTitle is column 3 but for VBA it's 2. Just a quirk.

VBA's not so bad... just gotta get the hang of it. You already seem to be doing pretty well at the events concepts (I saw another of your posts) so you should get up to speed quickly.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top