ComboBox behavior-- inconsistent... wrong record chosen

  • Thread starter Thread starter GGG
  • Start date Start date
G

GGG

I've got a record box: (table name: recordbox)
Which consists of A,b,c,d,e (ignore the numbers on the far right, just
for reference purposes)

A b c d e
1. 374 ember olive 3.5 5
2. 374 embery black 3.8 5
3. 374 embery blue 3.27 8
4. 374 embery green 3.1 5.7
5. 377 imbibed green 2.8 5
6. 377 imbibed yellow 2.75 8
7. 377 biog emerald 2.33 9

It pulls its' datasource from an underlying table.

Initially, it had no primary key field as there can be multiple records
with the same number (a). I have tried this example setting unique
keys to no avail.

It shows up fine in the combobox. It's code is, "select a,b,c,d,e
from recordbox"

I select record 2.
When the combobox reports back to the onExit event, it pulls the data
corresponding to record #1.
Same would go if I selected record #6. It would report back record
#5. See where I'm going?

It's onExit action is:

Me.Description.Value = GSANbr.Column(1)
Me.Color.Value = GSANbr.Column(2)
Me.Size.Value = GSANbr.Column(3)

Me.GSANbr.Value = GSANbr.Column(0)
NSN.SetFocus

These are the ones they refer to in the select query.

The only option I can think of (since I tried the first already to no
luck), is to set an ID associated with each record. That would be
cumbersome to me, and would like to try and make this work the way I
have it set up now.

Let me know if this is possible

Thanks
 
AFAIK, the only way to get the combo box control to select the correct
record is to use a primary key in the underlying table. add a primary key
field to the table, an Autonumber will do fine. add the Autonumber field to
the combo box control's RowSource, as the *first* field. increase the
ColumnCount property by 1. in the ColumnWidths property, put a zero (0)
followed by a semicolon at the *beginning* of the width settings. make sure
the BoundColumn property is set to 1. now the pk field is the bound column,
but is not visible in the droplist. in your code, increase each column
reference by 1, as

Me.Description.Value = GSANbr.Column(2)
Me.Color.Value = GSANbr.Column(3)

etc, etc.

hth
 
Back
Top