chaning bound column in VBA to get different values

G

Guest

Hey everyone, trying to figure this one out, any help is much apprreciated!!
I have a distribution table which has no key column (I know, I know, I want
one, believe me, but for many reasons they will not put one in). I have a
form, no control source, on which there is a listbox which lists Number,
Organization, Name and Date. Bound column is 1. There are 4 textboxes on
the form correspondnig to the listbox fields
What I'm trying to do is, when I click on an entry in the listbox, I want
each field in the listbox (Number, Orgn, Name and Date) to appear in it's
respective textbox. I put in some code, to have it cycle through the box,
change the bound column and put the value in the box. The code is listed
below. However, it does not work, in that all 4 boxes get filled in, but
only with the value from column 4. It's filling in the boxes, but not
correctly changing the column and getting the right value. Any ideas?

Private Sub Command24_Click()
List17.BoundColumn = 1
num = List17
List17.BoundColumn = 2
org = List17
List17.BoundColumn = 3
nam = List17
List17.BoundColumn = 4
dat = List17
End Sub
 
D

Douglas J. Steele

Private Sub Command24_Click()
num = Me.List17.Column(0)
org = Me.List17.Column(1)
nam = Me.List17.Column(2)
dat = Me.List17.Column(3)
End Sub

(note that the Column collection starts counting at 0)
 

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