Full Version: combo box returns number instead of Customer names
UtterAccess Forums > Microsoft® Access > Access Forms
namrezy
When I use a combo box that contains the customers names that I have, it always returns the ID number assigned from the Customer names table that I use for the combo box. Is there any way for it to return the text value that I see in the combo box rather than the ID number assigned to it in the Customer names table.
jmcwk
Check your Column Count if there are 2 Columns change the widths to 0;1.25

Combo Boxes are 0 based so the first Column is 0 the 2nd is 1 ordinarily the Primary Key Column, the first Column or Column 0 is hidden hence the 0; width and as you need Column 1 Visible it would have a width of 1.25 or wider if need be.

Edited by: jmcwk on Mon Aug 25 10:27:59 EDT 2008.
rkeifer
if I understand your problem, you need to change the bound column option under the data tab of the properties window of the combo box. In an apparant attempt to maximize developer confusion Microsoft has made the Combo Box Columns 0 based EXCEPT when specifying the bound column. The default value will be 1. So if you have two columns in your combo box, the bound column will show as column 1 which is column 0 in all other references to that column. So, to changer the bound column from column 0 to column 1, change the bound column property from 1 to 2. I know this can be confusing because I get confused just explaining it. Microsoft strikes again.
JVanKirk
As John said, you want to change column widths, not bound column. The bound column effects what value is stored, which you DO want to be the number assigned to each customer. By setting the first value to 0, it makes the ID column "invisible" and you will only see names.
rkeifer
The value returned by a combobox or al listbox is the value of the bound mcolumn of the selected row.
JVanKirk
That is the value returned, absolutley correct. If you set an unbound text box to =Comboboxname you would get the value of the combobox, however, what is displayed in the combobox is dependant on your visible columns or more accurately, the column widths. If you set column 1 to 0", then column 2 will be the first "visible" column in your combobox, so, if your rowsource has 2 columns, and ID field and a Name field and you set the two column widths to 0"; 1.5", you will get the name being displayed in the combobox. If your column widths were 1;1.5, the value/number, is what you would see in your combobox.
THAT being said however, LOL, the way the OP posts, after rereading this again...it does seem like maybe they want the name to be returned somewhere else. It does sound like the OP is seeing name in the combobox...so...
NAMREZY, do you see the name in the combobox when the list is dropped down, or can you still see it in the combobox after a slection is made? Are you trying to show the name from the combobox somewhere else on your form? Either way, you want your bound column of your combobox to be 1 if your ID field in your rowsource is in column 0, that way you are storing the ID in your table.
rkeifer
"Is there any way for it to return the text value that I see in the combo box rather than the ID number assigned to it in the Customer names table."
This was the sentance which led me to believe that the combo box was displaying the correct text but returning the key value from the Custome Names table.
jmcwk
Post deleted by jmcwk
rkeifer
We haven't heard from namrezy since he asked the question.
I hope he's not banging his head against a wall somewhere !
jmcwk
Amen to that ! But as you say he has not replied so ???? And he is offline so hopefully it has been resolved sad.gif
jmcwk
Lets start over and these are assumptions only

tblCustomers
pkCustomerID (Primary Key AutoNumber)
CustomerName (Text Data Type)

tblCustomerDetail
pkCustomerDetailID (Primary Key Autonumber)
fkCustomerID (Foreign Key to tblCustomers Number DataType)
etc.

Your Forms record source would be tblCustomerDetail OR a Query using both tblCustomers AND tblCustomerDetail. The Query Field(s) would include ALL of tblCustomerDetail and CustomerName from tblCustomers OR just CustomerDetail.

When you create the ComboBox Control for your CustomerName using the Wizard you will select tblCustomers as its Record Source as you will also be prompted where you want to store the value, in this case you would select fkCustomerID. After finishing look at the Column Count (should be 2) ,the Column Widths (should be something like 0;1.25) Bound Column (should be 1) Opening the Form using the pulldown you will see the CustomerName as it is within your tblCustomers Table however the CustomerID will be stored in your tblCustomersDetail Table. This is what you want.



Does that clear it up for you or have I further muddled the waters ?

Deleted my prior post as I replied to the wrong recipient blush.gif
Edited by: jmcwk on Mon Aug 25 16:38:08 EDT 2008.
JVanKirk
RKeifer,
Yes, that sentence does lead you to beleive that, i read one thing and understood another...displaying and returning got mixed around in my head between reading and replying...soooo.... sad.gif
Hopefully the OP has been able to resolve everything...
jleong
Hi,
on't mean to hijack the thread but...I have the same scenario where the customer name shows in the combo box and the primary ID for that customer is stored in the detail table. But when I use my search form it doesn't retrieve an results when searching by customer name. I manually entered a name in the table and used the seach form again with success only with the manually entered name.
Any ideas how to make it retrieve records with the customer name even though it's not stored in the detail table as the actual name?
Thanks!!
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.