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!

Question about combo box 1

Status
Not open for further replies.

asafb

Programmer
Jun 17, 2003
80
0
0
US
Hello I have a combo box whose source is a table called salespersons:

the table has the following fields:

salespersonid (number)

salespersonname (text)

no primary key no autonumber.

i have a combo box that points to that.

problem is when i select it as a value it returns the NUMBER not the actual text in a text box field like this:

=[Forms]![Switchboard]![Salespersonselect]

^^ this is the default value for one of my text box fields,
it gives me a NUMBER how do i get the TEXT.

it says: 4 (duh who's that?

it should say: Joseph

thanks guys
ab
 
Look at the table that the combo box is based on. Chances are the first column is the salespersonid column, which is a number. Here's how you fix it.

1) Change the combo box's Column Width's property (under the format tab in the combo box properties) to read 0";2"

2) Change the combo box's Bound Column property (under the data tab in the combo box properties) to read 2.
 
thank you for your help

perhaps i can be more specific.

I have a form where they select their name in the combo box. the combox bounds for now the ID (number) not (text). when they hit "Show me my records," it will open a form only showing their records using code:

stdocname = "contact form"
stlinkcriteria = "[SalesPersonID]=" & Me!Salespersonselect]
DoCmd.OpenForm stDocName, , , stlinkcriteria

^^
the following code opens the form with the criteria of pulling the records from the combobox as a number.

However, how do I do it so that on the form it says

you are logged in as john

??

so when i changed it to bound the other column do display the TEXT, while it did it perfectly on a simple form, when I copied over that to THIS form, i got an error message.
any way to fix this?
thanks!~
 
Maybe this approach may help:

(1) Keep the combo bound to the ID; it's a responsible way to keep unique track of names.

(2) The normal method of putting the Name (not ID) into a textbox is to explicitly refer to the specific column in the combo.

e.g. assume textbox named Text1, combo named Combo1(ID in first column, Name in second column)

In the AfterUpdate event of Combo1

Text1.value=Combo1.Column(1)

(3) Remember columns(1) refers to the second column because column indexes are zero-based. The reference Combo1 will only give the default value (bound value).

Let me know how it goes,
John
 
thanks john it worked!!!!!!!!!!!!!!!!!!!!!! :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top