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

Listbox Scrolling 1

Status
Not open for further replies.

cretanion

Technical User
Jan 28, 2002
53
US
I have this code to scroll through a listbox using a command button on a FORM:

On Error GoTo Error_Handler

' ListBox must have the Focus
Me.LstITM.SetFocus

' Force ListBox to start from the top ( I am having a problem here, because it is not starting at the top, running the report, then cycling down. Obviously this code will cycle to the next item in the list.)
Me.LstITM.ListIndex = Me.LstITM.ListIndex + 1

*** RUN A COMMAND TO PRODUCE A REPORT ***

Error_Handler:
If Err.Number = 7777 Then
' End of the list - Move to the start.
Me.LstITM.ListIndex = 0
Exit Sub
Else
MsgBox Err.Description, vbOKOnly, "Error #" & _
Err.Number & " occurred"
End If

This is what I would like to see...

I would like to click the command button, after choosing the item in the list, FIRST ONE, then takes the listed item and runs a report based on that item, then it cycles to the next item in the list, SECOND ONE. Press the command button again and so on...

Right now I get everything to work, but the first item is getting bypassed. I have tried For...Next, Do While... and I cannot get anything to work. Any response would be greatly apprecaited.

Thanks in advance,
 
Why don't you increment ListIndex after running the reporting commands. Also, is there any reason you need to start at that element and loop through? It would be easier to just:

Code:
Dim x as Integer
For x = 0 to LstITM.ListCount-1
    'Do your reporting commands here
Next x


-V
 
Thanks!!!


Is there any reason you need to start at that element and loop through?:
When the reports run they are inserted into an email. Before the reports are sent, the report are previewed in order to verify what is being sent is correct. It is just a check. Cannot get around this.

Why don't you increment ListIndex after running the reporting commands:
I am getting "error #0 occurred." Do you know how to trap this error with a message box (I am not familar with this at all.) If I click OK, it will cycle to the next item in the list, which is great, but not for a user running going through the list. If you need my code I can make it available.
 
I got the error handling problem sovled

Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top