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,
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,