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

How do I control value displayed in Combo Box?

Status
Not open for further replies.

InspiredKiwi

Technical User
Jan 3, 2008
4
FI
Hi folks,
I am trying to do some basic things in Access. I've got manuals on hand but some things I've not been able to find.

I have a combo box. It changes a numeric ID field in the table it's based on. Let's call this "UserID". UserID is also on another table that lists users (their names etc.). I have set up a Select query as follows:

SELECT jos_users.name, jos_users.username, jos_users.id FROM jos_users ORDER BY jos_users.name;

This enables me to see the numeric ID and the actual user name related to each ID. This is necessary because the end user can't identify "users" by their ID... they will need to see the name of the "user".

Everything works as I want except for one thing. I'd like the Combo box to display the username and not the ID. The box controls the ID but I want it to display the username.

Am I making sense? I do hope so!!

Is this possible?

With much thanks...

Jonathan
 
SOLVED.

I've managed to get this working.
Finally figured out the the first value SELECTed will display in the box. So I put the USERNAME as the first SELECT value and then changed the BOUND COLUMN to point to the new location of the ID.

Cheers,

Jonathan
 
As you are not use to access I suggest sing the wizard to create the combo box.

If you think you understand combo boxes then its the bound column which determines what is saved and the column width, column count, list rows and list width which determain what is seen in the drop down list.



Ian Mayor (UK)
Program Error
Always make your words sweet and nice. Because you never know when you may have to eat them.
 
Hi Jonathan,

Does your combo box display the data from a query? If so im guessing the first column is the userID? If you have the username in this query aswell, you can use the column count and column properties of the combo box. So if userid is the first column and username is the second, make the column count equal to 2, and then as you only want to show the username, set the column widths to 0cm;4cm (the 0cm hides the first column).

Just as an addition to this, say you have the query and you have 5 columns being selected but you only want to display the 2nd and last column in the combo box, you would set the count to 5, and set the widths up as 0cm;4cm;0cm;0cm;4cm. Also, instead of typing cm each time, you can just type 0;4;0;0;4 and when you press enter or choose a different property, the cm's will automatically fill for you.

Hope this helps,

Andrew
 
Thanks Andrew and Ian...
Whilst I posted that I'd "SOLVED" it... the information you have shared has given me much more understanding of how to manipulate the way these COMBOBOXes behave. I'll incorporate some of what you've shared.

Andrew... My form was pulling its data directly from a table. I have since realised I need to set up a query. I've tried setting one up but I am having trouble getting it to behave the way I want. It's too much to try and explain here though... someone would need to look at my database. I am not sure how much help is on offer here. Please advise.

My situation is that I have created a database which incorporates various tables I exported from an online application I am setting up for someone as a favour. The online application had no means for importing data into it. This friend has a few thousand existing records she wants in this online database. It would take a long time to enter them all in by hand so I thought I'd see if I could port the relevant tables over to Access and then set up some forms that work with the data appropriately. I think it should be relatively easy, but my lack of Access knowledge is making it rather tricky. I set up a number of databases about 12 years ago... and sadly much of the knowledge I picked up then has expired or been forgotten.

If someone is happy to look at this database even if just to let me know if what I wish to do is possible, please let me know.

With much thanks,

Jonathan

 
How are ya InspiredKiwi . . .

What displays in the the textbox portion of a combobox is determined by the [blue]Column Widths[/blue] property:
Microsoft said:
[blue]Column Widths:

In a combo box, the first non-zero width column is displayed in the text box portion of the control.[/blue]


Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
 
Hi Jonathan,

I could try to help you, my knowledge isn't that great yet aswell though! What is it that you want your query to do?

Andrew
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top