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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can't get the ListIndex Property workin!

Status
Not open for further replies.

NewfieGolfer

Technical User
Mar 29, 2001
80
CA
Hi All,

I have a combo box on form1. The user selects from the combo box. If the combo box doesn't contain the appropriate value, the user hits a button and opens another form (form2). They input the value in this form. The combo box on form1 is linked to that table. So, as the user inputs data into form2, the combo box on form1 populates.

On form 1, once the user makes the selection from the combo box (that has 4 columns) the data in each column is copied to 4 text boxes.

So if the data in the combo box looks like this:

x a b c
x f w d
x d w k
y w q p
y s e f

and i select row 2 (x f w d) or row 3 (x d w k) then the text boxes display the data in row 1. also, if i select row 4, the text boxes display the data in row 3.

Here's the code i use on the lost focus event of the combo box:

Dim varitem As Variant

varitem = Combo26.ListIndex

[text1] = Combo26.Column(0, varitem)
[text2] = Combo26.Column(1, varitem)
[text3] = Combo26.Column(2, varitem)
[text4] = Combo26.Column(3, varitem)


what am i missing here so that when i select a row, the text boxes display that values in that row?

Any help appreciated,
NG
 
It looks like Column 1 (well, column 0, to be precise) is your bound column, and it's on a duplicated field. So the only part about row two it really sees is the ""X" guy. Thus, the first X row.

It is probably better to do this in the C/B's AFTER_UPDATE event rather than the LOST_FOCUS. And I don't think you need the ListIndex guy...

Sub Combo26_AfterUpdate()
with me
![text1] = !Combo26.Column(0)
![text2] = !Combo26.Column(1)
![text3] = !Combo26.Column(2)
![text4] = !Combo26.Column(3)
End With
End Sub


Jim How many of you believe in telekinesis? Raise my hand...
Another free Access forum:
More Access stuff at
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top