Getting wrong information filling a textbox from a combobox

M

Marcos

I am trying to fill a text box based in the selection in a combo box.

It works, but if the combo box has 2 register with the same value in the
first column the text box is always filled with the information related to
the first register.

For instance: using the Northwind database I create a new form, put a combo
box and a text box.

In the row source property of the combo box I put “SELECT [Customers and
Suppliers by City].City, [Customers and Suppliers by City].CompanyName,
[Customers and Suppliers by City].ContactName, [Customers and Suppliers by
City].Relationship FROM [Customers and Suppliers by City] ORDER BY [City],
[CompanyName], [ContactName], [Relationship]â€

And in the control source property of the text box I put =Combo0.column(1)

The error is the following: when there are at least 2 customers from the
same city, the text box always shows the first’s CompanyName. Eg: there are 3
customers from Buenos Aires, it does not matter which of the 3 customers I
select, the company name displayed in the text box is always “Cactus Comidas
para llevar†who is the first customer from Buenos Aires.

Microsoft creates an article (209738) to show how to fill a textbox from a
combobox, but they did not make reference to this “problemâ€.

Is this an Access problem or do I miss something?

Thanks in advance,

Marcos
 
D

david epsom dot com dot au

It works, but if the combo box has 2 register with the same value in
first column the text box is always filled with the information rela
the first register.

Yes, a combo box only remembers the BOUND COLUMN.

You can change the bound column PROPERTY to 2 (CompanyName),
but if the Company is in more than one City, the combo box
will not know which City to use.

If you set the Bound Column Property to 0, then
the combo box will use the LIST INDEX.

The VALUE of a combo box is the value of the bound
column. If you use 0, then the value of the combo
box will be just a number, which is combo0.column(0).

(david)



Marcos said:
I am trying to fill a text box based in the selection in a combo box.

It works, but if the combo box has 2 register with the same value in the
first column the text box is always filled with the information related to
the first register.

For instance: using the Northwind database I create a new form, put a
combo
box and a text box.

In the row source property of the combo box I put “SELECT [Customers and
Suppliers by City].City, [Customers and Suppliers by City].CompanyName,
[Customers and Suppliers by City].ContactName, [Customers and Suppliers by
City].Relationship FROM [Customers and Suppliers by City] ORDER BY [City],
[CompanyName], [ContactName], [Relationship]â€

And in the control source property of the text box I put =Combo0.column(1)

The error is the following: when there are at least 2 customers from the
same city, the text box always shows the first’s CompanyName. Eg: there
are 3
customers from Buenos Aires, it does not matter which of the 3 customers I
select, the company name displayed in the text box is always “Cactus
Comidas
para llevar†who is the first customer from Buenos Aires.

Microsoft creates an article (209738) to show how to fill a textbox from a
combobox, but they did not make reference to this “problemâ€.

Is this an Access problem or do I miss something?

Thanks in advance,

Marcos
 
M

Marcos

Thanks David,

I have read the documentation about the BOUND COLUMN property but I was not
sure about the way to use it, now it is clear.

I am going to use the bound column with property 0 to get the listindex value.

Thanks again,

Marcos
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top