Listboxes - is this possible?

Jonno

Registered User.
Local time
Today, 16:53
Joined
Mar 17, 2003
Messages
74
Morning everybody.

Could someone please tell me if its possible with code to refer to a specific line/row in a list box, e.g.

From Listbox1 I want the data in row 3/column 2 for example.

I know you can reference the column in a listbox.

Hope this makes sense!
 
Code:
Me.MyListBox.Column(2, 3)
 
:D Thanks! :D
 
Pretty dangerous. What happens when the number of items in the RowSource changes? Are you going to remember the piece of code that refers to a specific row by its row number?
 
Hi Pat

I have a loop which counts the entries in a listbox and performs a function the number of times corresponding to the number of rows in the box -

Dim countstaff As Integer
Dim Counter As Integer
countstaff = Me!List14.ListCount


Dim Check
Check = True: Counter = 0
Do
Do While Counter < countstaff
Counter = Counter + 1

Dim myrecords As Recordset
Set myrecords = CurrentDb.OpenRecordset("universal", dbOpenDynaset)
With myrecords
.AddNew
!who = Me!who
!Date = Me!List8
!shift = Me!shift
!Day = Me!List8.Column(1)
!Clock = Me!List14.Column(1, Counter - 1)
!order = Me!List14.Column(2, Counter - 1)
!Name = Me!List14.Column(0, Counter - 1)
.Update
End With
myrecords.Close


If Counter = countstaff Then
Check = False
Exit Do
End If
Loop
Loop Until Check = False
Exit Sub



What this does is builds a number of records, one for each staffname in the listbox, which works ok.
 
What is the difference in functionality between the two? :confused:
 
Search for Bang vs Dot.

The Dot syntax is preferred because it provides intellisense and early binding.
 

Users who are viewing this thread

Back
Top Bottom