.Column(n) Not Returning Expected Value

G

Guest

I have a simple 2 column combo box that returns data from a single table
sorted ascending on both columns. Both columns contain ID numbers and column
2 is the primary key for the table. Column 1 can have duplicate numbers and
column 2 is an autonumber (unique) . When a selection is made, the .Column(1)
value returns the value of the first occurence of the value in .Column(0).

For example:

ID 1 ID 2
4 1
5 2
5 3
6 4

Regardless of whether the first number 5 is selected or the second number 5
is selected, the value of the second column in the combo box [Column(1)] is
always 2.

Any ideas about what am I missing?

Thanks.

Paco
 
G

Graham Mandeno

Hi Paco

The current row in a combo (or list) box is determined by the current Value
of the control and the first matching value in the BoundColumn. If the
Value is 5 and the BoundColumn is 1 then the current row will be the first
row that has a 5 in column 1 (the 2nd row). This is so irrespective of
whether the 2nd or 3rd row is highlighted.

It's always a good idea to make your BoundColumn one that has no duplicates.
Is it possible to redesign your app slightly so that the BoundColumm is 2?
Then Column(n) will give you the correct value for both columns.
 
G

Guest

Thanks, Graham.

Since the second column is unique, I just added it again as the first column
(now I have 3 columns) and bound it with a width of 0". That did the trick.

Graham Mandeno said:
Hi Paco

The current row in a combo (or list) box is determined by the current Value
of the control and the first matching value in the BoundColumn. If the
Value is 5 and the BoundColumn is 1 then the current row will be the first
row that has a 5 in column 1 (the 2nd row). This is so irrespective of
whether the 2nd or 3rd row is highlighted.

It's always a good idea to make your BoundColumn one that has no duplicates.
Is it possible to redesign your app slightly so that the BoundColumm is 2?
Then Column(n) will give you the correct value for both columns.
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

Paco said:
I have a simple 2 column combo box that returns data from a single table
sorted ascending on both columns. Both columns contain ID numbers and
column
2 is the primary key for the table. Column 1 can have duplicate numbers
and
column 2 is an autonumber (unique) . When a selection is made, the
.Column(1)
value returns the value of the first occurence of the value in .Column(0).

For example:

ID 1 ID 2
4 1
5 2
5 3
6 4

Regardless of whether the first number 5 is selected or the second number
5
is selected, the value of the second column in the combo box [Column(1)]
is
always 2.

Any ideas about what am I missing?

Thanks.

Paco
 
G

Graham Mandeno

Hi Paco

You didn't need to do that! Much easier to change BoundColumn to 2!
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

Paco said:
Thanks, Graham.

Since the second column is unique, I just added it again as the first
column
(now I have 3 columns) and bound it with a width of 0". That did the
trick.

Graham Mandeno said:
Hi Paco

The current row in a combo (or list) box is determined by the current
Value
of the control and the first matching value in the BoundColumn. If the
Value is 5 and the BoundColumn is 1 then the current row will be the
first
row that has a 5 in column 1 (the 2nd row). This is so irrespective of
whether the 2nd or 3rd row is highlighted.

It's always a good idea to make your BoundColumn one that has no
duplicates.
Is it possible to redesign your app slightly so that the BoundColumm is
2?
Then Column(n) will give you the correct value for both columns.
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

Paco said:
I have a simple 2 column combo box that returns data from a single table
sorted ascending on both columns. Both columns contain ID numbers and
column
2 is the primary key for the table. Column 1 can have duplicate numbers
and
column 2 is an autonumber (unique) . When a selection is made, the
.Column(1)
value returns the value of the first occurence of the value in
.Column(0).

For example:

ID 1 ID 2
4 1
5 2
5 3
6 4

Regardless of whether the first number 5 is selected or the second
number
5
is selected, the value of the second column in the combo box
[Column(1)]
is
always 2.

Any ideas about what am I missing?

Thanks.

Paco
 

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