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

Listindex Errror 1

Status
Not open for further replies.

ZOR

Technical User
Jan 30, 2002
2,963
GB
I am clocking through listboxes, I had no problem but the user gets an error message the listindex proprty has been used incorrectly. Any ideas

For C1 = 0 To Me.D1.ListCount - 1
Me.D1.SetFocus: Me.D1.ListIndex = C1 ' Clock List 1

For C2 = 0 To Me.D1b.ListCount - 1
Me.D1b.SetFocus: Me.D1b.ListIndex = C2 ' Clock List 2

For C3 = 0 To Me.D1b.ListCount - 1
Me.D1c.SetFocus: Me.D1c.ListIndex = C3 ' Clock List 3

' ==================================================================

rsTable1.AddNew
rsTable1.Fields("DOCDATA") = Trim(Me.DR3.Caption)
rsTable1.Update

' rsTable1.MoveNext

' ==================================================================
Next ' c3
Next ' c2
Next ' c1
 
How are ya ZOR . . .
Microsoft said:
[blue]This property is available only by using a macro or Visual Basic. You can read this property only in Form view and Datasheet view. [purple]This property is read-only[/purple] and isn't available in other views.[/blue]
Not quite sure what your doing here, but have a look at the [blue]Selected[/blue] property!

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
 
Thanks. Actually Ihave just looked at the the loops and they are wrong too. What I am trying to achieve is looping through the first list in an increment of 1 at a time. Then I want to loop the second list by an increment of 1 and then loop through everything that in the third list.

I am putting the row items that are in the third list into a table. I am putting it in via a label as there is another manual click routine involved.

The loops as they are simply increment each list in turn. Looked easy at the time but logically defective to say the least. Regards
 
Hell, even thats wrong. Increment List1 by 1 at a time
Increment List 2 1 at a time, Loop all List 3. THEN increment List 2 by another 1, Loop all List 3.

When List 2 empty, go back to List 1 and increment bu one more etc, etc.

Its basically going through folders for documents and filling List2 and 3 as it gets them
 
Is this then not allowed?

For TY = 0 To D1.ListCount - 1
Me.D1.SetFocus
Me.D1.ListIndex = TY
Next

Thanks
 
Although in the help section, which says the listindex is read only, it also states:

To set the ListIndex property value, you can use the following:

Forms(formname).Controls(controlname).SetFocus
Forms(formname).Controls(controlname).ListIndex = index

So am I correct setting the listindex in a loop??

Thanks
 
ZOR . . .

I don't know why you feel you have to use the Index property when your already accessing the listboxes directly. Example:
Code:
[blue]   For x = 0 to Me!ListboxName.ListCount-1
      Debug.Print Me!ListboxName.Column(1,x)
   Next[/blue]


Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
 
Many thanks. I am programaticaly clicking the listboxes in sequence to open diectories and folders to extract document paths into a table. I have thrown the loops out and doing it in code. I have adopted your suggestion of using the selected property and thats working well. The setting listindex just kept getting upset. Alls fine now, have a star and thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top