>I have a listbox and a timer on my form. This timer code updates the listbox every minute and highlights the last item in the listbox. The RowSource and RowSourceType are my table and fields.
>
>I commented out some lines of code that seem useless. The commented out lines used to walk me through the table until I reached the end, but now I use GO BOTTOM instead to do the same thing.
>
>Is this the best way to highlight the last item in the listbox?
>
>
>thisform.timer1.enabled=.f.
>thisform.faxit2
>THISFORM.lstFaxes.Requery
>THISFORM.lstFaxes.Refresh
>SELECT faxreq
>*!* IF !EOF()
>*!* DO WHILE ALLT(faxreq.status) = "SENT" OR faxreq.log_date < (DATETIME()-1*3600)
>*!* SKIP
>*!* IF EOF()
>*!* SKIP -1
>*!* EXIT
>*!* ENDIF
>*!* ENDDO
>*!* ENDIF
>thisform.timer1.enabled=.t.
>GO BOTTOM
>THISFORM.lstFaxes.ListIndex = recno()
>
I think, the code is fine as it is. Another way would be:
thisform.lstFaxes.ListIndex = thisform.lstFaxes.ListCount
If it's not broken, fix it until it is.
My Blog